How to find the distance of a position in a specific direction in 3d space.

103 Views Asked by At

I have the position data of a robot in a physics simulator and I want to know it's displacement from the origin in a specific direction. Normally this is when the specified direction is on the axis like the $x$-axis. Since it is just the $x$ value of the position vector for the robot.

However in this particular case I want to know the distance traveled in an arbitrary direction, say for example on a $30^o$ angle from the $x$-axis.

Also in my case the $x$ and $y$ axis form the plane the robot walks on the the $z$ axis goes up into the sky. I am interested in knowing how to find the general case of given an angle from the $x$-axis and the 3d position of the robot how far has the robot traveled in the direction specified?

1

There are 1 best solutions below

0
On BEST ANSWER

Let $\vec v$ be your position vector. Construct a unit vector $\vec u$ in the direction of interest. Then $\vec v \cdot \vec u$ is the distance traveled in the direction you want.