Question

Using OpenGL with an orthographic projection.

I've defined a plane in 3d. Its position and orientation are defined by a 4x4 matrix.

What I'd like to be able to do is sketch, with the mouse, in the plane.

I can find the intersection with the plane by casting a ray from the mouse into the screen. This point is in reference to the world coordinate system (OpenGL's identity modelview matrix) x+ right, y+ up, z+ out of the screen.

I've found a lot of examples of this, intersect a ray with a plane.

Now, how do I map that point to the plane's coordinate system? This has probably been answered in a related question but I can't seem to find it.

Was it helpful?

Solution

One way to define plane is by two non-colinear vectors and a base point.

p(u,v) = ↑r + u·↑a + v·↑b, where u,v are scalars

After doing the plane ray intersection you know the point of intersection with the plane ↑h, which by definition must lie on the plane. To get the values of u,v for that point you have to project the vector from ↑r to the intersection point onto the base vectors ↑a and ↑b:

u = (↑h - ↑r) · ↑a ; where '·' denotes the scalar product
v = (↑h - ↑r) · ↑b
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top