Click to See Complete Forum and Search --> : [RESOLVED] Translating a complex formula into C++


_Cobra
January 15th, 2007, 05:43 PM
I'm using a complicated distance formula in a program of mine and need a little help translating it into C++.
http://upload.wikimedia.org/math/b/f/8/bf8d19ce8c717304e4af7c44723017ea.png
http://upload.wikimedia.org/math/a/2/8/a28e3e65e329c3fdeb4ee5699e7c7758.png can be relpaced with x1,y1;x2,y2
http://upload.wikimedia.org/math/7/1/6/7163974bbf49a48802122e64fb2ed72c.png can be replaced with y2 - y1.

Thanks everyone!

Edit:
Nothing like trial and error:
Math::arctan((Math::sqrt(Math::pow(Math::cos(x2)*Math::sin(y2-y1)),2) + Math::pow(Math::Cos(x1)*Math::sin(y1) - Math::sin(x1)*Math::cos(x2)*Math::cos(y2-y1),2)))/(Math::sin(x1)*Math::sin(x2) + Math::cos(x1)*Math::cos(x2)*Math::cos(y2-y1)))

2MuchRiceMakesMeSick
January 16th, 2007, 05:13 PM
what is that for?

_Cobra
January 16th, 2007, 05:43 PM
It is a foruma to calculate the distance between two points on a sphere. First, convert the lat/long coordinates to radians then plug & chug. Multiply the answer by the radius of the sphere, and you've got the distance between two points.

Zaccheus
January 17th, 2007, 04:30 PM
Nice.
:)