Given start point, angles in each rotational axis and a direction, calculate end point

11,136

Solution 1

Based in the three angles you have to construct the 3x3 rotation matrix. Then each column of the matrix represents the local x, y and z directions. If you have a local direction you want to move by, then multiply the 3x3 rotation with the direction vector to get the result in global coordinates.

I made a little intro to 3D coordinate transformations that I think will answer your question.

3D Coordinates

3D coordinates

Solution 2

First of all, for positioning a point in 3D you only need two angles (just like you only needed one in 2D)

Secondly, for various reasons (slow cos&sin, gimbal lock, ...) you might want to store the direction as a vector in the first place and avoid angles alltogether.

Anyway, Assuming direction is initially z aligned, then rotated around x axis followed by rotation around y axis.

x=x0 + distance * cos (angleZ) * sin (angleY)

Y=y0 + distance * sin (Anglez)

Z=z0 + distance * cos (angleZ) * cos (angleY)

Solution 3

First, it is strange to have three angles to represent the direction -- two would be enough. Second, the result depends on the order in which you turn about the respective axes. Rotations about different axes do not commute.

Possibly you are simply looking for the conversion between spherical and Cartesian coordinates.

Share:
11,136
Nick Udell
Author by

Nick Udell

Developer, BSc (hons) Computer Science, University of Southampton PhD Computational Imaging, University of Southampton

Updated on June 04, 2022

Comments

  • Nick Udell
    Nick Udell almost 2 years

    I have a start point in 3D coordinates, e.g. (0,0,0).

    I have the direction I am pointing, represented by three angles - one for each angle of rotation (rotation in X, rotation in Y, rotation in Z) (for the sake of the example let's assume I'm one of those old logo turtles with a pen) and the distance I will travel in the direction I am pointing.

    How would I go about calculating the end point coordinates?

    I know for a 2D system it would be simple:

    new_x = old_x + cos(angle) * distance
    new_y = old_y + sin(angle) * distance
    

    but I can't work out how to apply this to 3 dimensions

    I suppose another way of thinking about this would be trying to find a point on the surface of a sphere, knowing the direction you're pointing and the sphere's radius.