Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If I understand you properly, then it should be as simple as making sure that the reflected sprite's angle (with respect to the diagonal line) is the same as the original sprite's angle (again w.r.t. the diagonal line) but negative.</p> <p>Showing this in an image (with the original sprite on the bottom left and the reflection on the top right):</p> <p><img src="https://i.stack.imgur.com/ZaZIf.png" alt="Reflecting about an angle"></p> <p>So if you look at the angles θ<sub>I1</sub> and θ<sub>R1</sub>, you can see that:<br> θ<sub>I1</sub> is the angle between the original image and the diagonal line<br> θ<sub>R1</sub> is the angle between the reflected image and the diagonal line</p> <p>These angles are equal and opposite, i.e. 55° and −55°.</p> <hr> <p>That might not be quite enough for you to work out the rotations needed in the general case though, so I'll go into a bit more detail. Basically, like I said before, the angle between the reflected sprite and the line needs to be equal and opposite to the angle between the original sprite and the line. This is the same as making sure the difference in angle between each sprite and the line, with respect to a common reference direction, is equal and opposite.</p> <p>Looking again at the image, assume that the common reference direction is to the right. It doesn't matter if you make this something else, as long as you're consistent. Also assume that the green arrows, on each sprite, would point parallel to the reference direction when the sprite has a rotation of 0°.</p> <p>So with that in mind you can see that the angle of the line θ<sub>L</sub> is 35° (with positive rotation being clockwise).</p> <p>You can also see that the rotation of the original sprite θ<sub>I2</sub> is 45°.</p> <p>So the angle between the original sprite and the line is θ<sub>I2</sub> − θ<sub>L</sub>, which equals 10°.</p> <p>Once again, the angle between each sprite and the line needs to be equal and opposite. That is:</p> <p>θ<sub>I2</sub> − θ<sub>L</sub> = −1 * (θ<sub>R2</sub> − θ<sub>L</sub>)</p> <p>To find the rotation needed for the reflected sprite, just rearrange that equation to this:</p> <p>θ<sub>R2</sub> = 2θ<sub>L</sub> − θ<sub>I2</sub></p> <p>Putting in the values for θ<sub>L</sub> and θ<sub>I2</sub> gives:</p> <p>θ<sub>R2</sub> = 2*35° − 45° = 25°</p> <hr> <p>So in this example the rotation of the reflected sprite θ<sub>R2</sub> is calculated to be 25°, which you can see is correct from the image. If you want to double check though, notice that the difference in angle between the reflected sprite and the line (θ<sub>R2</sub> − θ<sub>L</sub>) is −10°, which is equal and opposite to θ<sub>I2</sub> − θ<sub>L</sub>. Just remember to flip the reflected sprite before you apply this rotation (assuming the green arrow is the axis you flip it around).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload