1
votes

I have a starting point in 3D space (x,y,z) which corresponds to the center of a circle and an end point (x2,y2,z2) which corresponds to the surface of the sphere. I also have many other end points on the surface of the sphere (x3,y3,z3 for example) with each having the same radius length (rr).

I want to calculate the angle of movement from the center point (start) to the end point and for all my other end points. Eventually, given say 100 spheres, I want to see if the end points all move with similar directionality/angles from the center. Given this purpose, I would need a direction of say 0 and 360 to "look similar" so I think I need to use some type of specific plane.

The comment at the end of this post (https://math.stackexchange.com/questions/707673/find-angle-in-degrees-from-one-point-to-another-in-2d-space) has a nice graphic and answer using atan2 function but that is only for 2D space.

This post (Signed angle between two 3D vectors with same origin within the same plane) and this one Angle between 3 points in 3d space got me started.

This (The X angle between two 3D vectors?) is also helpful but calculates the wrong type of angle (I think) based on the horizontal system.

Given all that here's what I've come up with so far. Here are some points:

a =  c(-0.0684486861, 0.0125857380, 0.0201056441) #start/center of sphere
b = c(-0.0650557851, 0.0175286346, -0.0228805516) #end point

v1 = c( (a[1] - b[1]), (a[2] - b[2]), (a[3] - b[3]) ) #vector

Then I think I need to calculate the dot product between v1 and perhaps a vector parallel to the plane at 90 degrees from the 2 points? To then take cosine between the angles? But if the radius always the same isn't that easier?

I do not know enough of the math to figure this out for even a set of two points much less develop code for doing this for all my spheres/points. Guidance greatly appreciated.

1
Do you want to compute the angle between the center of the sphere and the endpoint from the point of view of the origin? or do you want to compute the angle between two endpoints, from the point of view of the center of the sphere?Juan Carlos Ramirez
Thanks for the question. I want to compute the angle from the center to the single endpoint from the origin.KNN

1 Answers

1
votes

Term "angle " is not applicable to direction between two 3D points.

Point difference D is vector. It is characterized by three components (x,y,z).

You can normalize this vector making unit one d and represent this direction as direction cosines where d.x = cos(angle between d and OX) and so on.

Also 3D direction might be represented in spherical coordinate system as angle theta between direction and OZ axis, and angle phi between projection of direction onto OXY plane and OX axis.

But for direction comparison there is no the only common approach. You need to define some metric according to your specific purposes. For example, scalar product of normalized vectors (as cosine of angle between directions)


If you have radius rr, sphere center C=(xc,yc,yc), two points on sphere P=(x1,y1,y1) and P2=(x2,y2,y2), then angle between directions from center to these points is angle between vectors:

V1 = P1 - C
V2 = P2 - C

is (using dot product and arccosine)

angle = acos( ((x1-cx)*(x2-cx) + (y1-cy)*(y2-cy) + (z1-cz)*(z2-cz)) / (rr*rr) )