Jump to content
  • Advertisement
Sign in to follow this  
Ezbez

Reflecting a point over a line

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'd like to reflect a point over a line. Basically, I will have a point P, where it is at (X,Y). And I have a line L that has a slope of M and runs through the origin. How would I get P to relfect over L? And, as importantly, will this be do-able in real-time? Thanks in advance! -Ezbez

Share this post


Link to post
Share on other sites
Advertisement
I don't understand that website. :(

It all confuses me. It never says what the 'n' with a little 'hat' opver it is. Also, it seems to be making a point equal a calculation(involving the 'n hat' and other points), but at least from a programming point of view, there would be two parts of the point, so therefore two seperate calculations. It pretty much just confuses me. If you could clear it up, that would help.

Share this post


Link to post
Share on other sites
The n is the normal vector. Its somthing you might remember from highschool physis or around then. You treat the line as the normal vector and the points as the other two points.

EDIT: i guess this might make it a bit clearer



Basically just shoot a ray from your original point to your origin, and then find the angles between that ray and the normal ray. The point will have the same angles and distance on the other side. So just shoot a ray (more of a line segment I guess) from the origin to the other side with the same distance using the angles you found before. The resulting point should be the reflected point. Hope that clears it up a bit.

As for real time, it depends on how you do the calculations (just with C syntax or your using an engine which takes advantage of SSE) but both should be fast enough I think.

[Edited by - Mistro on August 21, 2005 10:38:15 AM]

Share this post


Link to post
Share on other sites
Here: It's rubbish quality and my handwriting is very poor, but it should clear some things up if you have a little understanding of vector maths.

http://img.photobucket.com/albums/v231/kungfutortoise/reflection.jpg

To clear some things up: To get the normalised vector in direction r you divide the direction vector by its modulus (length) => r/|r| => r/(sqrt(x*x + y*y)) if r = (x, y). If you don't know the dot product then you can look it up somewhere or other, I expect.

Edit: If your line is in cartesian form then you'll want it to be a vector. The vector equation of a line through the origin is r = Sv, where v is the direction that the line is going in and S is your scalar variable. For calculating the reflection, you'll only be interested in the direction vector, v.

Hope that helped.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

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!