cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:
SOLVED!

# Hotlink Mirror on its axis

Participant

Hi,

I think this should be done by setting the hotlink element's transmat. However, I really cannot understand how to apply reflection/mirror.

I did some research and found this reference.

Based on the documentation,
x' = tmx[0] * x + tmx[1] * y + tmx[2] * z + tmx[3]

y' = tmx[4] * x + tmx[5] * y + tmx[6] * z + tmx[7]

z' = tmx[8] * x + tmx[9] * y + tmx[10] * z + tmx[11]

I tried to play around with the angle and mirror settings, but I got lost in betwee.
For example,
I placed the hotlink in 45Deg not mirrored,

Then I placed the hotlink in 45Deg mirrored,

If you will notice, tmx[0] and tmx[4] were negated.
I really don't know how to know which tmx index to negate.
I would appreciate it if you could guide me on this. (Helpful reference would be very much appreciated as well)

Note:
I did check the examples in the APIv27 Kit but i don't think there is a mirror example there (only angle rotation)

1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Mentor

Also, when working with matrices, keep in mind that the order of operations matters, e.g. flipping and then rotating is not the same and rotating and then flipping. Reflect that in your code, so when applying transformations B and C to matrix A:

A . B . C is not the same as C . B . A

Ralph Wessel BArch
Software Engineer Speckle Systems
3 REPLIES 3
Mentor

A matrix is transformed by multiplying it by a transformation matrix - don't think of this as just multiplying individual values. So a 4x4 matrix for a 45° rotation (A) looks like:

0.70710678118654757, -0.70710678118654746, 0, 0,
0.70710678118654746, 0.70710678118654757, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1

The transformation matrix to flip across the y axis (B) looks like:

-1, 0, 0, 0,
0, 1 0, 0,
0, 0, 1, 0,
0, 0, 0, 1

A . B looks like:

-0.70710678118654757, -0.70710678118654746, 0, 0,
-0.70710678118654746, 0.70710678118654757, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1

If you imagine the operations applied to a shape, mirroring also affects rotations. If you looked at a top spinning clockwise in a mirror it would appear to be spinning anti-clockwise, i.e. the mirror reverses the rotation direction. That's why you see multiple values change.

Ralph Wessel BArch
Software Engineer Speckle Systems
Participant

Thanks for the feedback.
I was able to get the equivalent transmat values based on your response by applying a combination of reflection and rotation (performed 2x2 matrix multiplication)

Solution
Mentor

Also, when working with matrices, keep in mind that the order of operations matters, e.g. flipping and then rotating is not the same and rotating and then flipping. Reflect that in your code, so when applying transformations B and C to matrix A:

A . B . C is not the same as C . B . A

Ralph Wessel BArch
Software Engineer Speckle Systems