Solve equation

Started by
6 comments, last by Acosix 4 years, 9 months ago

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:

mirror.thumb.png.73842e381ff6aae9a45d27e9dbb92ac5.png

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

Advertisement

Would you be able to use the superposition principle to compose a cylinder and parabolic? Perhaps you can solve two simpler solutions and compose the derivatives together. Just an idea. I have no idea if this would work for you, or how exactly to do it.

Just offsetting should not change the degree of the polynomial and with it the amount of possible solutions. Can't pinpoint your error exactly, because... one should get rid of stuff like square roots first. Otherwise things get (too) complicated and symbolic calculators don't seem to like that either :P

Wasn't one trick with ray-tracing or intersection problems in general to transform to object space to make the math simpler ? ;)

So here I'd just offset the start point of your ray - in the opposite direction. Now you're back to your original problem ... which you already know how to solve. Then transform the intersection point back and you're done.

 

Why in the seven holy-cannollies would you want to apply an anti-gravity physics model??????

Well if you wanted to use a model where would(i.e. of course) people play basketball in a curved stylish camera way...how would you apply it? I mean it is hard to calculate physics in basketball in the first place, what do you personally believe about the complexity of such physics computation? The rendering formula is almost impossible to calculate to begin with as when you get a good possible approximation to the formula(which would work, but an approximation formula is not much easier), even the best symbolic calculators would need 50 seconds of iteration to calculate?

And if it alone isn't complicated enough, what would the curved ground physics complexity of calculations look like?

Research:

https://en.wikipedia.org/wiki/Gravity

https://en.wikipedia.org/wiki/Newton's_law_of_universal_gravitation

I'm curious how you think you'd apply the gravitation formula?

I have no clue why you mention gravity. This is only a mapping from the world into an image sensor. 

I ended up using a non analytic method where I have computed the space of the mirror as a matrix. I can then easily transform position and direction into a space that is aligned with the mirror axis.

Before sampling I add an offset from the point to the Z axis and after sampling I offset away from the axis again.  I discard cases where the offset point hit the mirror within the offset radius.

basket2.thumb.png.ad2df4196a3e26853fb2ead4b0712ca8.png

 

This seem to work :)

 

 

 

 

Well making a 3D map based on a 2D basketball field sounds cool.

But when you try to display that into a curved display, you have to re-specialiaze the code to too many data possibilities as the ball might be bouncing off the floor correctly but it would really inefficient by the RAM usage factor and the CPU multi-threading. Why it is so I explained in my previous post.

In short..the ball bouncing would be really hard to display.

This topic is closed to new replies.

Advertisement