# 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:

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.