Estoy convirtiendo una función de javascript a java, y no entiendo el propósito de los ores bit a bit en el siguiente código:
(Math.tan(PHId)) ^ 2) - ¿Esto garantiza que el número siempre termine en 2?
(Et ^ 6)
El código es parte de una biblioteca para convertir referencias de cuadrículas irlandesas a/desde latitud y longitud: http://www.nearby.org.uk/tests/geotools2.js
GT_Math.E_N_to_Lat = function(East, North, a, b, e0, n0, f0, PHI0, LAM0) { //Un-project Transverse Mercator eastings and northings back to latitude. //Input: - _ //eastings (East) and northings (North) in meters; _ //ellipsoid axis dimensions (a & b) in meters; _ //eastings (e0) and northings (n0) of false origin in meters; _ //central meridian scale factor (f0) and _ //latitude (PHI0) and longitude (LAM0) of false origin in decimal degrees. //'REQUIRES THE "Marc" AND "InitialLat" FUNCTIONS //Convert angle measures to radians var Pi = 3.14159265358979; var RadPHI0 = PHI0 * (Pi / 180); var RadLAM0 = LAM0 * (Pi / 180); //Compute af0, bf0, e squared (e2), n and Et var af0 = a * f0; var bf0 = b * f0; var e2 = (Math.pow(af0,2) - Math.pow(bf0,2)) / Math.pow(af0,2); var n = (af0 - bf0) / (af0 + bf0); var Et = East - e0; //Compute initial value for latitude (PHI) in radians var PHId = GT_Math.InitialLat(North, n0, af0, RadPHI0, n, bf0); //Compute nu, rho and eta2 using value for PHId var nu = af0 / (Math.sqrt(1 - (e2 * ( Math.pow(Math.sin(PHId),2))))); var rho = (nu * (1 - e2)) / (1 - (e2 * Math.pow(Math.sin(PHId),2))); var eta2 = (nu / rho) - 1; //Compute Latitude var VII = (Math.tan(PHId)) / (2 * rho * nu); var VIII = ((Math.tan(PHId)) / (24 * rho * Math.pow(nu,3))) * (5 + (3 * (Math.pow(Math.tan(PHId),2))) + eta2 - (9 * eta2 * (Math.pow(Math.tan(PHId),2)))); var IX = ((Math.tan(PHId)) / (720 * rho * Math.pow(nu,5))) * (61 + (90 * ((Math.tan(PHId)) ^ 2)) + (45 * (Math.pow(Math.tan(PHId),4)))); var E_N_to_Lat = (180 / Pi) * (PHId - (Math.pow(Et,2) * VII) + (Math.pow(Et,4) * VIII) - ((Et ^ 6) * IX)); return (E_N_to_Lat); }Recomiendo preguntar al autor del guión.
Sin embargo, estoy razonablemente seguro de que esto es simplemente un error, y lo que se quiere decir es Math.tan(PHId) ** 2 / Math.pow(Math.tan(PHId), 2) y Et ** 6 / Math.pow(Et, 6) , es decir, exponenciación en lugar de OR bit a bit. Yo creo esto porque
E_N_to_Long , Lat_Long_to_East , Lat_Long_to_North ) usan Math.pow todas partes, E_N_to_Lat es el único que se usa ^Estoy convirtiendo una función javascript a java
Observe el comentario en la parte superior de la secuencia de comandos :
* Credits * The algorithm used by the script for WGS84-OSGB36 conversions is derived * from an OSGB spreadsheet (www.gps.gov.uk) with permission. This has been * adapted into PHP by Ian Harris, and Irish added by Barry HunterAconsejaría comenzar con estas fuentes primarias, en lugar de traducir la traducción de JavaScript de una traducción de PHP de una traducción de matemáticas de fórmula de hoja de cálculo a Java.