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