Math Error with rotations
|
|
LillyX Lane
Registered User
Join date: 1 Jun 2007
Posts: 8
|
10-20-2007 04:51
Hi all,
I have a script that gives a math error when assigning a rotation to another rotation. The error can occur at TotalRot = Rot1 and/or TotalRot *= Rot2. basicaly it does:
Rot1 = ZERO_ROTATION; Rot1 = Rot1 / llAxisAngle2Rot(Axis1, Angle1);
Rot2 = ZERO_ROTATION; Rot2 = Rot2 / llAxisAngle2Rot(Axis2, Angle2);
//step1 TotalRot = Rot1; //step2 TotalRot *= Rot2;
When I cut out the function that gives the error into another script, it sometimes generates the same error or just works! So I don't have an example code that generates the error (yet). I checked many times if there are any changes of Rot1 before it gets assigned to TotalRot but it doesn't. They are definied in the scope if a function
I am wandering about the rotations. I suppose using llAxisAngle2Rot() always gives a valid quaternion for Rot1 and Rot2. So a math error when assigning one rotation to the other cannot give an error. However it does. Does anyone have suggestions ?
(I'll try to get and example her that generates the error)
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
10-20-2007 08:36
Sure you aren't running into a bounds check error? As in: vector total;
default { touch_start(integer total_number) { vector a = <123,65,86>; vector b = <89,23,286>; total = a; total *= b; llSay(0, (string)total); } }
(BTW, lslint will not check a vector dot product. "Invalid operator: vector = float.". I'll post it in the lslint thread) Returns: "[8:33] Object: <123.00000, 65.00000, 5590.00000> [8:33] Object: Script run-time error [8:33] Object: Bounds Check Error"
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
10-20-2007 08:41
even switching to this:
vector total;
default { state_entry() { vector a = <4,5,8>; vector b = <2,3,2>; total = a; total *= b; llSay(0, (string)total); } }
will return: [8:40] Object: <4.00000, 5.00000, 40.00000> [8:40] Object: Script run-time error [8:40] Object: Bounds Check Error
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
10-20-2007 09:00
dang dyslexia and selective vision. Read the wiki wrong and lslint was right Would have expected dot product to be a * b = <  a.x * b.x), (a.y * b.y), (a.z * b.z)> But it doesn't. Look at the wiki again: * Vector dot product <1,2,3> * <4,5,6> = (1 * 4) + (2 * 5) + (3 * 6) = 32
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
LillyX Lane
Registered User
Join date: 1 Jun 2007
Posts: 8
|
10-20-2007 22:37
Hi Jesse,
Yes, that is a tricky error. I checked the types and they are all rotations, no unexpected conversions to float or some other type.
I have separated the faulty function in 2 functions and that works fine. Still no idea what went wrong because the sequence of calculations and the values passed are exactly the same.
Thanks for your help
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
10-21-2007 05:45
From: LillyX Lane Hi Jesse,
Yes, that is a tricky error. I checked the types and they are all rotations, no unexpected conversions to float or some other type.
I have separated the faulty function in 2 functions and that works fine. Still no idea what went wrong because the sequence of calculations and the values passed are exactly the same.
Thanks for your help Sorry, I don't always state myself clearly. Check the output of these lines by using a say: TotalRot = Rot1; llOwnerSay((string)TotalRot); It is going to return a rotation But TotalRot *= Rot2; llOwnerSay((string)TotalRot); Is going to return a float, if it is going to return anything It shouldn't even compile because you already have typecast TotalRot as a rotation and you can not change it to a float To check yourself then do something like this: TotalRot = Rot1; float output_test = TotalRot * Rot2; llOwnerSay((string)output_test);
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|