1

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.

KNN
  • 459
  • 4
  • 19
  • 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 Apr 17 '19 at 21:52
  • Thanks for the question. I want to compute the angle from the center to the single endpoint from the origin. – KNN Apr 18 '19 at 01:00

1 Answers1

2

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) )
MBo
  • 77,366
  • 5
  • 53
  • 86
  • Thank you for your comment. I'm having a hard time following you. I understand D is a vector length between two points -in my case (x,y,z to x2,y2,z2). Isn't this vector already normalized since all my points have the same euclidean distance from the center point? And what would OX represent in my example? – KNN Apr 18 '19 at 14:51
  • D is just vector. Normalized `d=D/ rr` (because `rr=Len(D)`). OX is coordinate system axis – MBo Apr 18 '19 at 15:07
  • Okay. So how could I apply this to find the angle using my example? In my example d for each simulated point =1. Since if D= 0.435, rr = 0.435, since the distance/radius from center to point was fixed. So how do I calculate angle? Based on your link do I set unit basis vectors, ex, ey and ez to 90 degrees and how would this syntax work? Sorry for my lack of knowledge. – KNN Apr 18 '19 at 17:36
  • Angle Is measured between **two vectors**. To measure angle, you need two vectors. I see one - from sphere center to some point at the sphere. What is the second one? – MBo Apr 19 '19 at 02:33
  • Thank you for those additions. I understand now. I was using wrong terminology and should be thinking the "direction" from center point since I technically only have the one vector from 2 points. Direction unfortunately, seems to be above my knowledge too. – KNN Apr 19 '19 at 22:06