THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 24/12/2005 at 10:59, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 8.2 +
Platform: Windows ; Mac ; Mac OSX ;
Language(s) : C++ ;
---------
Howdy,
I have a problem with comparing a saved rotation with the current rotation. They should be exactly the same but they're not. They print out the same, even if I set the printout to six decimal places, but the comparison is always returning false after a position change and an undo.
Here's the code:
Vector opRot = op->GetRot(), savedRot = tagData->GetVector(SAVED_ROTATION);
if(opRot != savedRot)
{
GePrint("rotation changed");
GePrint("opRot = "+RealToString(opRot.x,-1,6)+","+RealToString(opRot.y,-1,6)+","+RealToString(opRot.z,-1,6));
GePrint("savedRot = "+RealToString(savedRot.x,-1,6)+","+RealToString(savedRot.y,-1,6)+","+RealToString(savedRot.z,-1,6));
}
The rotation is saved at the end of the tag's execution and should be the same the next time the tag executes if the object hasn't been rotated. The problem arises when I change the position of the object and do an undo. It then prints to the console that the rotation changed (and the two vector printouts are the same) when really only the position changed.
Of course an easy fix for it was this code:
Vector opRot = op->GetRot(), savedRot = tagData->GetVector(SAVED_ROTATION);
if(opRot != savedRot)
{
Bool sameRot=TRUE;
GePrint("opRot = "+RealToString(opRot.x,-1,6)+","+RealToString(opRot.y,-1,6)+","+RealToString(opRot.z,-1,6));
GePrint("savedRot = "+RealToString(savedRot.x,-1,6)+","+RealToString(savedRot.y,-1,6)+","+RealToString(savedRot.z,-1,6));
if(RealToString(opRot.x) != RealToString(savedRot.x)) sameRot = FALSE;
if(RealToString(opRot.y) != RealToString(savedRot.y)) sameRot = FALSE;
if(RealToString(opRot.z) != RealToString(savedRot.z)) sameRot = FALSE;
if(!sameRot)
{
GePrint("rotation changed");
}
else GePrint("rotation same");
}
But, I don't understand why the first code doesn't work after a position change and an undo. A position change alone doesn't make the comparison fail. Is there an imprecision in the roundoff and how many decimal places does the number actually have, or how many decimal places does the comparison check?
Adios,
Cactus Dan