Find point of Ray using origin and direction

I have a Ray object with origin and direction.
I need another point on the Ray line.
The main purpose is to use this two points for calculating the intersection between the Ray and the plane in wich every point is z = 0 (plane Z) with the help of math.js library.
How can i do it?
Is there a better and maybe built in method to achieve the main purpose?

You don’t need a library for this.

By varying scale factor “m” you get all points on the ray with the help of the following three equations, with point “p”, origin “o” and direction “d”:

1. p.x = o.x + m * d.x
2. p.y = o.y + m * d.y
3. p.z = o.z + m * d.z

Since you know the target z-coordinate of the point and also the z-components or origin and direction (3rd equation), that gives you the value of “m”.

Then plug that “m” into equations 1 and 2 to get the x, y components of your target point.

That is NOT equation for 3D line.
Try this: \frac{x-x_0}{a} = \frac{y-y_0}{b} = \frac{z-z_0}{c}
Coefficient m_x == m_y == m_z is not always true,

Is this method an option? three.js docs

1 Like

We are talking about straight lines. In that case the m_x must be equal to m_y and m_z.

Think of the vectorial way to write my equations:

CodeCogsEqn

That’s the equation for straight 3D line. You are confusing 2D with 3D.

Never interrupt someone who is making a fool out of himself.

For you I’ll make an exception, though:

2D is a special case of 3D. If something is valid in 3D, it can’t be invalid in 2D.

I do not understand what you just said. If you still believe that is the case google it.

That’s obvious.