Calculate Inverse Coordinate

Theory

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.

clip_image002

clip_image004

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:

clip_image006

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.

clip_image008

Application

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);

if(latlong.Longitude>0)
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: http://rbrundritt.spaces.live.com/blog/cns!E7DBA9A4BFD458C5!280.entry

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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