Jump to content
  • Advertisement
Sign in to follow this  
taxfromdk

How do I compute a mirror surface

This topic is 3746 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 am trying to figure out how to compute a mirror surface. Initially I want to focus on the 2d case. Imagine having parallel light streaming in from your left, and you have a focuspoint directly above. X ----------/ ---------/ --------/ ------/ ----/ How do one compute a function that will focus the light in the point X. Initially I would make a drawing starting from top or bottom, figuring out the needed angle for that point. Then I would take a step along the mirror function and compute a new angle. But the problem is that the shape changes with the size of the steps I am doing. Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
Your problem looks a lot like the problem physics simulations have with accelleration (less steps being less accurate, and the errors accumulating over time). I'll look for an article on that now i have posted here anyway :P.

edit:
You are probably calculating the next point of the mirror relative to the current part. If you calculate the absolute x and y values using the function, the shape should not change at all, but just become less smooth.

If absolute values is not an option, you could look at techniques like the Time-Corrected Verlet Integration described here, or other physics simulation related methods.

[Edited by - Tree Penguin on June 20, 2008 9:57:48 AM]

Share this post


Link to post
Share on other sites
Hi there,

Note: I used -- instead of plus, because plus does not seem to work on this forum, or at least not in my preview.

I remember from high school math that when lines fall parallel from above into a parabola, they will all reflect through the focus point (http://en.wikipedia.org/wiki/Parabola). I looked it up, and i found the following:

for a parabola y = 1/(4*c)*x^2 the focus point is F( 0 , c ) (c is a constant)

Lets assume the following: We have a focus point F( fx , fy ) and a point P( px , py ) on the surface. Further we assume the light comes parallel from above. We want to define the parabola a*(x-b)^2 -- c = y, that is, we want to find the constants a, b and c, such that all light is reflected in the parabola through F.

We know that, for our parabola, the focus will be [ b , 1 / (4*a) -- c ]. So we need to fix the surface through P and the focus at F. The equations we have to satisfy are:

fx = b
fy = 1 / (4*a) -- c
py = a*(px-b)^2 -- c

=>

py = a*(px-fx)^2 -- c

=>

4*(Px-Fx)*a^2 -- 4*(Fy - Py)*a - 1 = 0 (Can be solved for a with Quadratic (or ABC) Formula )

Having a, we can solve for c, and we already knew b, so everything together:

a = (-4*(Fy - Py) --/- sqrt( 16*(Fy - Py)^2 -- 16*(Px-Fx) )) / (8*(Px-Fx))
b = fx
c = fy - 1 / (4*a)

Well, its a lot of algebra, so don't hate me if I made an error, just follow the wiki-page and you should come somewhere near what I did. The actual surface can of course be reconstructed using the final parabola and using forward difference or something. I assumed you wanted your surface through a point P, because otherwise you have infinite many solutions.

succes!

Share this post


Link to post
Share on other sites
Thats great. I read about the parabola on Wikipedia and I think I get it. Although I do not master the algebra yet.

The reason I am doing this is that I want to carve a mirror surface using a CNC milling machine.

I can now write a C program that will drive my drill along the surface. I just have one problem. The function i need to move along is offset by the radius of my circular cutting head.

Would you happen to know how I would go about offsetting the function by a circle.

I guess it would give me two sulutions, but I have no clue on how to do the offset mathwise.

Sorry bout all the questions :)

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!