Ray-plane intersection to find the Z of the intersecting point
Posted
by
Jenko
on Game Development
See other posts from Game Development
or by Jenko
Published on 2011-01-12T18:18:31Z
Indexed on
2011/01/12
19:58 UTC
Read the original article
Hit count: 473
I have a rectangle in 3d space (p1, p2, p3, p4)
and when the mouse rolls over it I need to calculate the exact Z of the point on the rect, given the mouse coordinates (x, y)
.
Would a Ray-plane intersection find the Z of the intersecting point?
Edit: Would this one-liner work? .. it returns the t
value for the intersection, apparently the Z value.
float rayPlane(vector3D planepoint, vector3D normal, vector3D origin, vector3D direction){
return -((origin-planepoint).dot(normal))/(direction.dot(normal));
}
© Game Development or respective owner