Hi Guys,
I am looking into the mathematics of a curved mirror. More specifically this mirror:
http://paulbourke.net/dome/LucyCamera/
I dont have it in my hand yet but that does not keep me from modelling its behavior. I have therefore written a simple raytracer for how rays are reflected on the surface.
I assume the surface to be parabolic, as in
z = r² = sqrt(x²+y²)²=x²+y²,
where z is the height of the mirror and r is the radius in x, y.
Using a point and a direction P and D I can write
x=Px+u*Dx
y=Py+u*Dy
z=Pz+u*Dz
Pz+u*Dz = (Px+u*Dx)²+(Py+u*Dy)²
Pz+u*Dz = Px²+ u²*Dx²+2*u*Dx*Px+Py²+ u²*Dy²+2*u*Dy*Py
0= u²* (Dx² + Dy²) + u* (2*Dx*Px+2*Dy*Py-Dz) + Px²+Py²+- Pz
Finally I end up with 2. degree formula, that I can solve using https://en.wikipedia.org/wiki/Quadratic_equation
It ends up in 0, 1 or 2 values of U that I can use to find the X, Y and Z coordinates. With the point I can find the two tangent vectors and cross them to reveal a surface norma. that i can reflect around.
It reveals (when adjusting location and size of camera and image) images like this:
That is great and all, but I feel my mirror spend too many pixels on areas just below the mirror. I would therefore like to make the surface of the mirror steeper by offsetting all points on the surface against the axis of the mirror. The surface should then be something like.
z = (r+A)² , where A is an offset I would add
My problem is now that I have no idea how to solve the equation, as it explodes in complexity.
I tried typing it into Sage,
u, px, py, pz, dx, dy, dz, A = var('u px py pz dx dy dz A')
S = solve([(sqrt((px+u*dx)^2+(py+u*dy)^2)+A)^2==pz+u*dz], u)
print S
[
u == -1/2*(2*dx*px + 2*dy*py - dz + sqrt(-4*A^2*dx^2 - 4*A^2*dy^2 -
4*dy^2*px^2 - 4*dx^2*py^2 - 4*dx*dz*px + dz^2 + 4*(2*dx*dy*px -
dy*dz)*py + 4*(dx^2 + dy^2)*pz - 8*(A*dx^2 + A*dy^2)*sqrt((dx^2 +
dy^2)*u^2 + px^2 + py^2 + 2*(dx*px + dy*py)*u)))/(dx^2 + dy^2),
u == -1/2*(2*dx*px + 2*dy*py - dz - sqrt(-4*A^2*dx^2 - 4*A^2*dy^2 -
4*dy^2*px^2 - 4*dx^2*py^2 - 4*dx*dz*px + dz^2 + 4*(2*dx*dy*px -
dy*dz)*py + 4*(dx^2 + dy^2)*pz - 8*(A*dx^2 + A*dy^2)*sqrt((dx^2 +
dy^2)*u^2 + px^2 + py^2 + 2*(dx*px + dy*py)*u)))/(dx^2 + dy^2)
]
Instead of getting two nice solutions, I get two solutions where u appar on both sides of the equation.
I cant compute that!?!?
What to do next?
Kind regards
Jesper