Line-Plane Intersection

closed account (2NywAqkS)
I'm following this example on finding the intersection point between a plane and a line. (it's about three quarters down)
http://paulbourke.net/geometry/pointlineplane/

However this seems to only show how to solve u.

1. I don't understand what u is.
2. How do I find out the intersection point, in terms of (x, y, z)?

Thanks,
Rowan.

Two points define a line.
In order to find other points in the line you could simply interpolate them
C_J = \alpha A_J + (1-\alpha) B_j

So varying \alpha you can obtain all the points in the line.

The formula that you linked will give you the \alpha of the intersection point of the line with the plane
... and finally this \alpha they call u.
closed account (2NywAqkS)
Thanks guys!

Could you just check this function is okay then, for returning the coords?
 123456789101112131415 bool linePlaneIntersection(plane pln, vertex3 p1, vertex3 p2, vertex3 *intersect) { double u = (pln.n.x * p1.x) + (pln.n.y * p1.y) + (pln.n.z * p1.z) + pln.d / (pln.n.x * (p1.x - p2.x)) + (pln.n.y * (p1.y - p2.y)) + (pln.n.z * (p1.z - p2.y)); if (u <= 0.0 || u > 1.0) { return false; } else { intersect->x = u * p1.x + (1-u) * p2.x; intersect->y = u * p1.y + (1-u) * p2.y; intersect->z = u * p1.z + (1-u) * p2.z; return true; } }
I would suggest you to overload the operations in vertex3.
Like with std::valarray'
 12345678 template T dot(const std::valarray &u, const std::valarray &w){ return (u*w).sum(); } //... double u = dot(pln.n, p3-p2) / dot(pln.n, p1-p2); *intersect = u*p1 + (1-u)*p2;

Edit: as you are using normal vector and delta to define the plane, I think that the formula is
u = (pln.d-dot(pln.n, p2)) / dot(pln.n, p1-p2);` (maybe confused p1 with p2)
Last edited on
Topic archived. No new replies allowed.