0

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')

  • When you say angle, I'm assuming you mean on the X-Y plane? Otherwise, you either need to know the plane that the angle exists in, or a second angle. – Foo Barrigno Aug 19 '13 at 11:09

1 Answers1

2

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.

bubba
  • 43,483
  • 3
  • 61
  • 122
  • thanx Mr bubba for your answer. but from this type the end points are not correct – user90960 Aug 19 '13 at 11:20
  • ur procedure is not correct any other procedure – user90960 Aug 19 '13 at 11:22
  • His procedure is correct unless there is any additional information in the question. Please clarify your question. – Foo Barrigno Aug 19 '13 at 11:23
  • actually for this procedure my end points are not comming (corrected end points are -61495,755,137184) – user90960 Aug 19 '13 at 11:26
  • In your example, $z$ and $z'$ are different, so the line must not be horizontal (parallel to the $xy$ plane). So, your angle $\theta$ is not as I assumed. You need to explain what your $\theta$ means. – bubba Aug 19 '13 at 11:36
  • Angle Theta is 64.322 degs – user90960 Aug 19 '13 at 11:38
  • 1

    Angle Theta is 64.322 degs -- Yes, you said that already. The question is about its meaning, not its value. Where is it measured from? In what direction? Where is $\theta = 0$?

    – bubba Aug 19 '13 at 13:19