[Math] Given a point (x,y,z) and an angle/bearing distance calculate the end point (x,y,z)

3d

I'm not very mathematical but I'm working on a 3d program and for this part I simply want to draw a line.

I know the starting vector (x,y,z), the length r of the line and the bearing/angle. I want to calculate the endpoint so I can draw the line.

I had a look around and I'm using the following. Let θ be the angle in radians, and let d be the distance. Then the other endpoint is (x′,y′,z′), where:

X=3500
Y=0
Z=2000

r=150000
angle= 64.322

What is my End Point (x',y',z')

Best Answer

Assuming that "bearing" is an angle measured in the $xy$-plane, with $\text{bearing} = 0$ on the $x$-axis, we have: $$ x' = x + r*\cos(\theta) \\ y' = y + r*\sin(\theta) \\ z' = z $$ If your angle is in degrees, remember to convert it to radians before you pass it to the sine and cosine functions.

Alternative

It actually looks like your angle $\theta$ is measured in the $xz$-plane. So, the relevant formulae are: $$ x' = x - r*\cos(\theta) \\ y' = y \quad \text{(roughly)} \\ z' = z + r*\sin(\theta) $$ Since the line is 3D, you need two angles to determine its direction. You only gave us one ($\theta$) so that's why the formula for $y$ doesn't give the right answer. Actually, the results for $x$ and $z$ are not 100% accurate, either. With only one angle, this is the best possible.