08-11-2003 06:26
As some people have already discovered, it is virtually impossible to compare rotations using normal mathematical operators.

for instance, the following code normally returns FALSE, even though rot1 and rot2 are obviously equal:

CODE
`integer RotEqualityTester(){    rotation rot1 = llEuler2Rot(<33.33, 25.25, 70.70> * DEG_TO_RAD);    rotation rot2 = rot1;    return (rot1 == rot2);}`

The problem here is that rots use floats for the element values, and because of the nature of rots, 7 points of precisions just isn't accurate enough to truely identify a specific rotation.

However, since 5 decimal places of precision are enough accuracy for most uses, you can use the following function to compare two rots, with significant accuracy:

CODE
`integer CompareRots(rotation rot1, rotation rot2){    return (        llRound(rot1.x * 10000) == llRound(rot2.x * 10000)        && llRound(rot1.y * 10000) == llRound(rot2.y * 10000)        && llRound(rot1.z * 10000) == llRound(rot2.z * 10000)        && llRound(rot1.s * 10000) == llRound(rot2.s * 10000)        );}`

Using the previous example, we now get true if we use this function instead of the equality operator:

CODE
`integer RotEqualityTester(){    rotation rot1 = llEuler2Rot(<33.33, 25.25, 70.70> * DEG_TO_RAD);    rotation rot2 = rot1;    return CompareRots(rot1, rot2);}`
_____________________
Grim

"God only made a few perfect heads, the rest of them he put hair on." -- Unknown