Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Analytic method for calculate a mirror angle

I have in a 3D space a fixed light ray Lr and a mirror M that can rotate about the fixed point Mrot, this point is not on the same plane of the mirror, in other words the mirror plane is tangent to a sphere centered in Mrot with a fixed radius d. With that configuration I want to find an equation that receives point P as parameter and results with the rotation of the mirror in a 3D space.

We can consider that the mirror plane has no borders (infinite plane) and it's rotation have no limits. Also, the mirror reflects only on the opposite side of its rotation point.

In the picture are two cases with different input point P1and P2, with their respective solution angles alpha1 and alpha2. The pictures are in 2D to simplify the drawings, the real case is in 3D. fsd

At the moment I am calculating the intersection with the mirror plane in a random rotation, then calculate the ray reflection and see how far is from the point (P) I want to reach. Finally iterate with some condition changing the rotation until it match.

Obviously it's an overkill, but I can't figure it out how to code it in an analytic way.

Any thoughts?

Note: I have noticed that if the mirror rotates about a point (Mrot) contained in it's plane and the ray light is reaching that point (Mrot) I can easily calculate the the mirror angle, but unfortunately is not my case.

like image 942
zaccaro Avatar asked Jul 10 '15 06:07

zaccaro


2 Answers

First note that there is only one parameter here, namely the distance t along the ray at which it hits the mirror.

For any test value of t, compute in order

  1. The point at which reflection occurs.
  2. The vectors of the incident and reflected rays.
  3. The normal vector of the mirror, which is found by taking the mean of the normalized incident and reflected vectors. Together with 1, you now know the plane of the mirror.
  4. The distance d of the mirror to the rotation point.

The problem is now to choose t to make d take the desired value. This boils down to an octic polynomial in t, so there is no analytic formula[1] and the only solution is to iterate.[2]

Here's a code sample:

vec3 r;   // Ray start position
vec3 v;   // Ray direction
vec3 p;   // Target point
vec3 m;   // Mirror rotation point

double calc_d_from_t(double t)
{
    vec3 reflection_point = r + t * v;
    vec3 incident         = normalize(-v);
    vec3 reflected        = normalize(p - reflection_point);
    vec3 mirror_normal    = normalize(incident + reflected);
    return dot(reflection_point - m, mirror_normal);
}

Now pass calc_d_from_t(t) = d to your favourite root finder, ensuring to find the root with t > 0. Any half-decent root finder (e.g. Newton-Raphson) should be much faster than your current method.


[1] I.e. a formula involving arithmetic operations, nth roots and the coefficients.
[2] Unless the octic factorises identically, potentially reducing the problem to a quartic.

like image 131
PBS Avatar answered Oct 27 '22 08:10

PBS


I would do it as 2 separate planar problems (one in xy plane and second in xz or yz plane). The first thing that hits my mind is this iterative process:

mirror iteration

  1. start

    • mirror is turning around Mrot in constant distance creating circle (sphere in 3D)
    • so compute first intersection of Lr and sphere
    • or find nearest point on sphere to Lr if no intersection found
    • compute n0 normal as half angle between Lr and red line from intersection to P
    • this is mirror start position
  2. place mirror (aqua) to n0 angle

    • compute reflection of Lr
    • and compute half angle da0 this is step for new iteration
  3. add da0 to n0 angle and place mirror to this new angle position

    • compute reflection of Lr
    • and compute half angle da1 this is step for new iteration
  4. loop bullet 3 until

    • da(i) is small enough
    • max number of iteration is reached

[Notes]

  • This should converge into solution more quickly then random/linear probing
  • the more distant P from mirror (or smaller radius of rotation) the quicker convergence there is
  • Not sure if analytic solution to this problem even exists it looks like it would lead to transcendent system ...
like image 21
Spektre Avatar answered Oct 27 '22 08:10

Spektre