简体   繁体   中英

3D point from existing point, direction and distance

If I have an arbitrary point in 3D space "origin" (Ox, Oy, Oz), and a rotation in degrees (or radians) (Rx, Ry) and a distance (D) how can I calculate a new 3D coordinate for "target" (Tx, Ty, Tz)?

Am looking for C# code or dumbed-down mathematical notation.

在此处输入图片说明

In order to answer the question, some suppositions need to be made. If these suppositions don't fit your case, you might need to rename the X,Y,Z below and maybe change the order of operations.

Supposing the following situation:

  • X points East
  • Y points Nord
  • Z points up
  • When there is no rotation, the target would sit on the positive X-axis
  • A small positive rotation Rx would rotate the target towards the Y-axis
  • A small positive rotation Ry would rotate the target upwards
  • Suppose Rx and Ry are expressed in radians (because sin and cos need radians as input); if needed divide the degrees by 180 and multiply with pi

In that case:

  • Create an initial point (Px,Py,Pz) = (D, 0, 0)
  • Rotate P around the Y-axis by angle Ry to get a point Q=(Qx,Qy,Qz):
    • Qx = cos(Ry)*Px - sin(Ry)*Pz
    • Qy = Py
    • Qz = sin(Ry)*Px + cos(Ry)*Pz
  • Rotate Q around the Z-axis by angle Rx to get a point S=(Sx,Sy,Sz):
    • Sx = cos(Rx)*Qx - sin(Rx)*Qy
    • Sy = sin(Rx)*Qx + cos(Rx)*Qy
    • Sz = Qz
  • Add the origin to S to get T:
    • Tx = Sx + Ox
    • Ty = Sy + Oy
    • Tz = Sz + Oz

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM