"Mirroring" an angle
I need to obtain the supplement of an angle.
Exactly what I need to do is to implement some kind of code that mirror the angle, let's say, I have 45 degrees -> 13开发者_如何学运维5, another example: 80 ->100, 0 degrees -> 180, and so on.
I think you're after 180 - yourAngle
.
Your examples:
- 45 degrees: 180 - 45 = 135
- 80 degrees: 180 - 80 = 100
- 0 degrees: 180 - 0 = 180
Subtraction will probably work (if the universe is Euclidean).
http://en.wikipedia.org/wiki/Supplementary_angles
The simplest answer, based on what you appear to be asking about is
angle2 = 180 - angle1
mirrored_Angle = 180 - angle
if mirrored_Angle < 0:
mirrored_Angle = 360 + mirrored_Angle
reflected_angle = 180 - ray_angle
If you view your "angle" as a 2D vector in the plane, you simply change the sign of the component normal to the "mirror" plane.
So, for example, a 45 degree angle (1, 1) "mirrored" in the yz-plane becomes (-1, 1).
I was playing around with a rope physics project of mine and used this to mirror angles.
mirroredAngle = -(yourAngle % 360)
This will work with values over 360 degrees because the modulus operation normalizes your angle, and subtracting that result from 0 will mirror it horizontally.
精彩评论