I have direction vector (0.000000, 0.707107, 0.707107) like this, i want to convert this vector to an angle between X, Y and Z direction planes and Direction vectors (0,45 deg,45 deg). Please provide the mathematical equations or VBA functions to get an angle.
Asked
Active
Viewed 387 times
-3
-
`Please provide the mathematical equations or VBA functions to get an angle.` - SO is not a research service. Learn some basic vector math / linear algebra, and attempt to write the code yourself, before asking here. – meowgoesthedog Jul 11 '18 at 17:24
-
thanks @meowgoesthedog. it is very simple. Cos(theta) = (U.V)/(|U||V|) – balaji Jul 12 '18 at 08:20
-
1It is indeed very simple - in-fact, simple enough to be easily Googled. – meowgoesthedog Jul 12 '18 at 08:44
1 Answers
-1
To get angle between vector D = (dx, dy, dz)
and coordinate planes, you can use scalar product of vector and its projection onto corresponding plane.
For example, to get projection on OYZ plane, you can just make x-component zero.
P(0yz) = (0, dy, dz)
S = D.dot.P = 0 + dy * dy + dz * dz
Fi(D, 0yz) = ArcCosine(S / (length(P) * length(D)) =
ArcCosine((dy*dy + dz*dz) / Sqrt((dx*dx + dy*dy + dz*dz)*(dy*dy + dz*dz)))=
ArcCosine(Sqrt((dy*dy + dz*dz) /(dx*dx + dy*dy + dz*dz))))=
ArcCosine(length(P) / length(D))
You can build similar formulas for OXY and OXZ planes

MBo
- 77,366
- 5
- 53
- 86