1

I need to search a line in a 3D space. I have a starting point (coordinates) of the line and the angle at which it is suppose to go (relative to each of the axis).
I need to start from the starting coordinates and search every element (every coordinate contains an element) $1$ by $1$ until I find one that matches the condition.

Imagine a bullet going through air to some target.

Doesn't seem that hard, but I haven't managed to find the solution for this.

In 2D space this would be something like

$$y = x\cos(\mbox{angle}) + \mbox{startPosition}$$

I assume you'll need $2$ formulas for my problem. Any idea how to solve it?

zoran404
  • 119
  • The answer you want to read there is not the accepted one, but the top-voted one. –  Dec 25 '14 at 21:02

1 Answers1

1

A line parallel to the nonzero vector ${\bf v} = (a, b, c)$ through the starting point ${\bf x}_0 = (x_0, y_0, z_0)$ can be traced by the constant-speed parameterization $${\bf x}(t) := {\bf x}_0 + t{\bf v}.$$

In our case, the starting position ${\bf x}_0$ is given, as are the angles $\alpha, \beta, \gamma$ the line respectively makes with the $x$-, $y$-, and $z$-axes.

We can work out $a, b, c$ by evaluating the dot product between the velocity vector ${\bf v}$ and the unit vectors ${\bf i}, {\bf j}, {\bf k}$ respectively in the positive $x$-, $y$-, and $z$-directions: On the one hand, $${\bf v} \cdot {\bf i} = |{\bf v}| |{\bf i}| \cos \alpha = |{\bf v}| \cos \alpha,$$ and on the other $${\bf v} \cdot {\bf i} = (a, b, c) \cdot (1, 0, 0) = a,$$ which gives $$a = |{\bf v}| \cos \alpha.$$ Similarly, \begin{align} b &= |{\bf v}| \cos \beta \\ c &= |{\bf v}| \cos \gamma \\ \end{align} So, the parameterization with (positive) speed $v := |{\bf v}|$ is $$\color{#df0000}{{\bf x}(t) = (x_0, y_0, z_0) + v (\cos \alpha, \cos \beta, \cos \gamma)}.$$

Travis Willse
  • 108,056
  • What would the angles α,β,γ be? The angles between x and y, y and z, z and x maybe? In which order is this? Is it clockwise or counterclockwise? – zoran404 Dec 26 '14 at 13:14
  • This is exactly the data that you have (or so I understood your question to say): Each is the "angle at which it is suppose to go (relative to each of the axis)." In other words, if you take the direction vector $\bf v$ and a vector pointing in the positive $x$-direction, $\alpha$ is the angle between those two vectors. – Travis Willse Dec 26 '14 at 17:53