Sign in to follow this  

Points on a sphere

This topic is 3574 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there, Was just wondering if anyone had an example C or Java file, or formula for calculating the spherical distance between two 3d vector locations on a sphere. I made a method for Euclidean distance but its not as accurate. Is it as simple as just finding the dot product between two vectors? Thanks! Dan

Share this post


Link to post
Share on other sites
Quote:
Original post by ibebrett
Off the top of my head i would say get the angle between the two and then multiply by the radius of the sphere to get the distance.

Indeed. BTW, the most robust and accurate way to get the angle between two 3D vectors is θ = atan2(||A×B||, A·B).

Share this post


Link to post
Share on other sites
Thanks for the fast reply!

By : θ = atan2(||A×B||, A·B).

I know AxB is the cross product, but what are the lines surrounding the cross product, it looks like the cardinality.

Sorry im new to Geometry.

Thanks!
Dan


Share this post


Link to post
Share on other sites
Quote:
Original post by daemon2008
Thanks for the fast reply!

By : θ = atan2(||A×B||, A·B).

I know AxB is the cross product, but what are the lines surrounding the cross product, it looks like the cardinality.

Sorry im new to Geometry.

Thanks!
Dan
The above equates to:
angle = atan2(length(cross(A,B)), dot(A,B))
Does that clear things up?

Share this post


Link to post
Share on other sites
Quote:
Original post by DonDickieD
Shouldn't it be:

theta = atan2( length( cross( A, B ) ), dot( A, B ) / length( A ) / length( B ) )
You might be thinking of the method that uses acos().

The method posted above works because:
|AxB| = sin(angle(A,B))|A||B|
A.B = cos(angle(A,B))|A||B|
And:
atan2(sin(angle(A,B))|A||B|, cos(angle(A,B))|A||B|) = angle(A,B)
That's rather informal, but should show (more or less) why it's not necessary to factor in the product of the lengths explicitly.

Share this post


Link to post
Share on other sites

This topic is 3574 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this