6

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.

zaccaro
  • 93
  • 7
  • Could you elaborate more on the way the mirror can move? is it like Spektre assumed on the surface of a sphere? Do you assume just one side of the plane reflects? – Sebastian Cabot Jul 10 '15 at 14:09
  • @SebastianCabot The mirror rotates respect to point `Mrot` and all posible rotations derive to a costant distance from the mirror surface to point `Mrot`. Just like @Spektre assumed. And the reflection surface is the oposite side of the mirror that faces the `Mrot` like @Spektre proposed. – zaccaro Jul 10 '15 at 23:12

2 Answers2

5

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.

PBS
  • 1,389
  • 11
  • 20
  • How does the distance to the rotation point makes a difference. He really just needs to find the intersection point and the normal. Could you explain further. This is very interesting – Sebastian Cabot Jul 10 '15 at 14:35
  • @SebastianCabot: As far as I understood the question, M is constrained to lie some fixed distance from Mrot. Without this constraint you can arrange for the mirror to reflect Lr to P at any point, so the problem is to find the reflection point to respect the distance-to-rotation-point constraint. – PBS Jul 10 '15 at 14:39
  • Yes, that is true. But is the constraint enough to allow you to find the solutions? I am still trying to figure it out and I wanted to better understand your reasoning. Regardless of the constraint we need to solve: Rvec = 2*dot(Nvec,IVec)*NVec - Ivec. Since Psource and Pdest are known we can further reduce it to -Pdest = 2*(dot(NVec,IVec))*NVec -PSrc. If we use normalized vectors I think we can write: norm(PSrc) - norm(Pdst) = 2*cos(ang(Nvec,IVec))*norm(n) - So we are still left with finding the angle based on the constraint you specified which I don't understand how you propose to do? – Sebastian Cabot Jul 10 '15 at 14:54
  • We don't need to know cos(ang(Nvec, Ivec)) because it's just a normalisation constant for n. I've now edited that part of the answer. – PBS Jul 10 '15 at 15:34
  • How can it be just t? You don't know which ray to follow. That is the all point. But I am probably missing something which to you seems obvious. – Sebastian Cabot Jul 10 '15 at 17:54
  • Isn't the ray direction fixed? The question seems to state that the ray's initial position, initial direction and target position are all fixed, and it's just the mirror that can rotate. – PBS Jul 10 '15 at 22:01
  • Are you considering that in the point 1 of your algorithm, for a fixed given distance `t` we have more than one posible Mirror positions? – zaccaro Jul 11 '15 at 00:28
  • @zaccaro: I don't think we do - once you've fixed t, the configuration of the source, reflection point and target is also fixed. Then there is only one possible mirror position that could cause the ray to reflect in this way. – PBS Jul 11 '15 at 01:21
  • Thats right. But in that case, we would need to construct the quartic formula for every different target point `P`, isn't it? – zaccaro Jul 11 '15 at 02:16
  • @zaccaro: I'm afraid so, though it's not actually too bad. I'll try to post it later. – PBS Jul 11 '15 at 08:04
  • @PBS (+1) nice approach much better then mine. btw the iteration is also not so bad (you just need to check the mirror range radius-es so `t` is not in so big range ... – Spektre Jul 11 '15 at 08:29
  • Even after all the edits something is missing. You now assume you know the ray direction v. I agree you need to iterate but over other parameters. And unfortunately I fear it is more complicated – Sebastian Cabot Jul 11 '15 at 18:07
  • @SebastianCabot: I think this assumption is allowed. Even if the ray direction were not fixed, then you could choose an arbitrary ray direction and still be able to place the mirror. Perhaps the OP could clarify? – PBS Jul 11 '15 at 18:16
  • Depends if you are looking for a specular reflection which has just one solution or for a diffused reflection which may have more than one solution. I don't think you can assume you know v. A point of light emits in all directions – Sebastian Cabot Jul 11 '15 at 18:21
  • I see what you mean. But isn't the question meaningless if we allow diffuse reflection? The question specifically says "a fixed light ray". – PBS Jul 11 '15 at 18:38
  • It looks like you are right about the question. I may have interpreted it more general than necessary. I have that tendency. – Sebastian Cabot Jul 11 '15 at 18:48
  • @PBS Good approach, I think that in the last line of your algorithm you where trying to say: `return dot(reflection_point - (m+mirror_normal*d), mirror_normal);` where d = distance from mirror to `m`. Could be? – zaccaro Jul 12 '15 at 09:37
  • @zaccaro: If we change the return value to what you suggest, then we would instead need to solve `calc_d_from_t(t) = 0` in the next step. – PBS Jul 12 '15 at 12:20
  • @PBS Totally right, I missed the `calc_d_from_t(t) = d` ;) – zaccaro Jul 12 '15 at 12:52
1

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 ...
Spektre
  • 49,595
  • 11
  • 110
  • 380
  • Is a fast iterating procedure that I would prefer to use over my actual method, but I think would be faster an algorithm without the need of iterate. – zaccaro Jul 10 '15 at 23:26
  • @zaccaro as I wrote in notes I am not sure if one exists you should add some more info and constraints of solution for example is radius of rotation fixed? what is the position of ray in relation to Mrot? how big is the Mirror? What are the roattion angles limits and axises,... etc ... and a sketch would be a good idea so it is absolutely clear what is what (keep in mind many people here are not natively english speaking me included and the terminology s not always the same from country to country) – Spektre Jul 11 '15 at 07:39
  • 1
    @zaccaro btw just occur to me that if the ray is not in one axis then this can not be done as separated problems and you need to iterate booth plane together (first xy, then xz, then xy, then xz, ...) because tilt in one axis will shift the other plane reflection – Spektre Jul 11 '15 at 08:18