Help to Mirror a vector

Hello all !

I am struggling with a rather simple patch: I am trying to model the reflection of a ray of sun on a mirror ( I guess a 3d planar symmetry on the Normal of the mirror ? ).

I haven t used transforms for years and my brain seem to just snap on this, any help would be greatly appreciated !

Mirror_ray.v4p (40.6 KB)

1 Like

hey Joanie,
the formula for reflecting a vector on a surface with normal vector n is:

reflection = vec - (2 * dot(vec, n) * n)

where n is normalized.

here is a patch implementing it:

Mirror_ray_formula.v4p (34.7 KB)


Thank you sooooo muuuuuccccchhhh <3 !!
I was starting to look into the formula and patching, but your implementation saved me a lot of headache :) Thanks !! Will keep you posted on the outcome, trying to make a solar projector !


The solar projector prototype is slowly taking shape, even if it’s a lot more challenging than I expected…

I’m now trying to reverse @tonfilm calculation and solve the mirror angle from the reflection and sun vectors, and my brain still can’t figure out the right function (my projections are drifting slowly with the sun’s position) :/ Any help would be amazing :)

Mirror_ray_formula_mirror_angle.v4p (68.7 KB)


1 Like

Bonjour Joanie

Je sais pas si j’ai bien compris ton problème de rotation, mais je pense qu’ avec rotate et inverse, tu peux trouver facilement la rotation de ton quad.


Inverse LookAt
Mirror_ray_formula_mirror_angle.v4p (64.9 KB)

Thanks a lot for looking @lecloneur !
It’s not quite there unfortunately, the orientation should match the reference mirror (top left in the patch; in blue).

I re-uploaded a clearer patch that better explains the challenge.

Mirror_ray_formula_mirror_angle.v4p (68.7 KB)

1 Like

Isn’t this a simple Cross product?

Ah reflection from two vectors, this would need more data since there would be quite a lot of solutions

So you have sun point, you have reflected point and mirror position, and you want to align plane

1 Like

I have sun and reflection vectors, and I’m trying to figure out the mirror orientation.
Here’s a better patch that explains what I’m after, with the solution (C) to double check.

Mirror_ray_formula_mirror_angle.v4p (68.7 KB)

Here’s a tip from mirror / sun master @elliotwoods !!
Not sure how to implement it yet, but the best lead I guess.

mirror normal = norm(norm(direction towards sun) + norm(target - mirror position))

it becomes much simpler if you think in directions instead of rotations.

then you have the direction from the mirror to the sun and to the destination. the normal vector of the mirror is then simply the average, or center, between them:


Mirror_ray_formula_mirror_angle2.v4p (71.2 KB)

EDIT: you can omit the multiplication by 0.5 because the vector gets normalized anyway. So it becomes simply a + operation.


yes, exactly, this is what the patch above does. :)

1 Like

My savior @tonfilm <3