Anonymous | Login | Signup for a new account 2020-01-21 04:10 PST
 Main | My View | View Issues | Change Log | Roadmap | Summary | My Account

View Issue Details  Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005942opensim[REGION] Script Functionspublic2012-03-24 09:362012-07-28 14:33
ReporterKayaker Magic
Assigned To
PrioritynormalSeverityminorReproducibilityalways
StatusnewResolutionopen
PlatformOSOS Version
Product Version
Target VersionFixed in Version
Summary0005942: llAngleBetween returns NaN for some rotations when 0.0 is the expected answer
DescriptionFor some rotations, llAngleBetween returns NaN when I was expecting 0.0 because the two rotations were identical. It doesn't happen with all rotations, just sometimes. I captured this example rotation that repeats the problem by displaying the rotation returned from llGetRot() of a moving vehicle.
Steps To ReproduceCreate a prim, put the script below into it and save.
Note that the llAngleBetween returns NaN in this case while the two reference functions return the correct answer of 0.0
I attempted to diagnose the problem by comparing the results to the reference function from the LSL Wiki. I thought the problem could be fixed by checking for zeros and negatives, but this turned out to be unnecessary (the tAngleBetween function) because the simple reference function gets the correct answer without all the testing.
Additional Informationfloat sAngleBetween(rotation a, rotation b)
{
return 2.0 * llAcos(
(a.x * b.x + a.y * b.y + a.z * b.z + a.s * b.s)
/ llSqrt(
(a.x * a.x + a.y * a.y + a.z * a.z + a.s * a.s)* (b.x * b.x + b.y * b.y + b.z * b.z + b.s * b.s)
)
);
}
float tAngleBetween(rotation a, rotation b)
{
float n=(a.x * b.x + a.y * b.y + a.z * b.z + a.s * b.s);
if (llFabs(n)<0.000001)
return(0.0);
float d=(a.x * a.x + a.y * a.y + a.z * a.z + a.s * a.s) * (b.x * b.x + b.y * b.y + b.z * b.z + b.s * b.s);
if (d<0.000001) return(0.0);
return 2.0 * llAcos(n / llSqrt(d));
}
default
{
state_entry()
{
rotation ang1=<0.000000, 0.000000, -0.087156, 0.996195>;
rotation ang2=<0.000000, 0.000000, -0.087156, 0.996195>;
llOwnerSay("LSLib says: "+(string)llAngleBetween(ang1,ang2));
llOwnerSay("simple says: "+(string)sAngleBetween(ang1,ang2));
llOwnerSay("tested says: "+(string)tAngleBetween(ang1,ang2));
}
}
TagsNo tags attached.
Git Revision or version numberwhere do I git a git revision number?
Run Mode Grid (Multiple Regions per Sim)
Physics EngineODE
Script Engine
EnvironmentUnknown
Mono VersionNone
ViewerDoesn't matter, Phoenix o
Attached Files

 Relationships

 Notes SignpostMarv (reporter) 2012-07-28 14:33 Cannot reproduce bug on master (using last night's version :P) Interestingly, the example script is broken in Second Life but works fine in OpenSim.

 Issue History Date Modified Username Field Change 2012-03-24 09:36 Kayaker Magic New Issue 2012-07-28 14:33 SignpostMarv Note Added: 0021929