Calculate Inverse Coordinate


The inverse of a spherical coordinate can be calculated by taking the inverse of the latitude (θ) and offsetting the longitude (Φ) by 180˚. The following formulas can be used to calculate these values.



The sgn function, known as the sign function and signum function, is a complex function that extracts the sign of a real number. This function has the following characteristics:


The inverse of a Cartesian coordinate can be calculated by taking the x, y, and z components of the coordinate and multiply them by -1.



The function to calculate the inverse coordinate will take in a VELatLong object and will return a VELatLong object. There is not a sgn function in the JavaScript Math class but we can do this using simple logic.

function inverseSpherical(latlong)
var lat = -1*latlong.Latitude;
var lon = 180-Math.abs(latlong.Longitude);

lon *= -1;

return new VELatLong(lat,lon);

Listing 1 Inverse Spherical Coordinate

The following algorithm calculates the inverse coordinate of a Cartesian coordinate. This algorithm takes in a Cartesian coordinate and returns a Cartesian coordinate.

function inverseCartesian(p1)
return new Cartesian(-1*p1.X,-1*p1.Y,-1*p1.Z);

Listing 2 Inverse Cartesian Coordinate

The following post has additional information on the Cartesian object:!E7DBA9A4BFD458C5!280.entry


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s