#### Archived

This topic is now archived and is closed to further replies.

# directional projection onto an arbitrary plane

This topic is 5271 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hi guys! How would you create a matrix that can handle directional projection onto a plane? i''m currently playing around with that, but there''s no suitable solution at the moment for me. has someone an idea how to do that? thx in advance, thomas

##### Share on other sites
a better explanation:

point p, direction d, plane e.

i think it is really easy to create a matrix that will project p onto e by d.

but how?

##### Share on other sites
Given a point and a direction, you have the equation for a line. Simply find the intersection of that line with the plane. Your plane equation looks like:

ax + by + cz + k = 0

where (a, b, c) is the normal and k is an offset from the origin.

That's one equation.

Your line can be written in parametric form as 3 equations:

x = d.x * t + x0y = d.y * t + y0z = d.z * t + z0

You can find (x0, y0, z0) by plugging in (p.x, p.y, p.z) for (x, y, z) and the known values of d. Therefore, the only remaining unknown is t. Once you known (x0, y0, z0), plug those 3 equations in for x, y, and z in the plane equation above. You will now have one equation and one unknown, the infamous t. Solve that 1 equation algebraically for t, then plug into the 3 x, y, z equations to get your intersection point!

Take care to handle the special cases when d.x, d.y, and/or d.z are zero. And when a, b, and/or c are zero. In the former cases, note that x, y, and/or z will be a constant value independent of t and so you just plug the constant value into the plane equation. In the latter case one or more of the terms of the plane equation will drop out.

Graham Rhodes
Principal Scientist
Applied Research Associates, Inc.

[edited by - grhodes_at_work on June 7, 2004 1:46:29 PM]

##### Share on other sites
Hum... Okay. I know this will be a solution... But how can i create this so it fits into a matrix M?

I''d like to multiplicate this matrix with every vertex, to get the directional projected vertex. like with planar projection shadows, so i can do this calculation on the GPU side.

Algorithm:

Create directional projection matrix: Mprojection
Multiply the current modelview matrix with this special projection matrix

Vprojected = M * Vorigin

Is it even possible?

-Thomas

##### Share on other sites
I don''t know the answer to this question, but I seem to remember that the book ''3D Math Primer'' includes code to create a matrix that projects onto an arbitrary plane. So you might look into that.

##### Share on other sites
You may want to take a look at Mark Kilgards ''stencil reflections and shadows'' (or something like that) on the NVidia website. I seem to remember it building up a matrix that did what you say.

Hope you find it.

1. 1
Rutin
25
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633309
• Total Posts
3011302
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!