2024-05-20 08:23 PM - edited 2024-05-20 08:35 PM
Hi,
Can you please help me, I'm really struggling on how can I mirror the hotlink via API.
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)
Solved! Go to Solution.
2024-05-25 09:46 AM
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
2024-05-21 03:14 PM
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:
The transformation matrix to flip across the y axis (B) looks like:
A . B looks like:
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.
2024-05-25 12:26 AM
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)
2024-05-25 09:46 AM
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