| Anonymous | Login | Signup for a new account | 2013-05-19 16:02 UTC | ![]() |
| Main | My View | View Issues | Change Log | Roadmap | Summary | My Account |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | |||||
| 0005942 | opensim | [REGION] Script Functions | public | 2012-03-24 16:36 | 2012-07-28 21:33 | |||||
| Reporter | Kayaker Magic | |||||||||
| Assigned To | ||||||||||
| Priority | normal | Severity | minor | Reproducibility | always | |||||
| Status | new | Resolution | open | |||||||
| Platform | OS | OS Version | ||||||||
| Product Version | ||||||||||
| Target Version | Fixed in Version | |||||||||
| Summary | 0005942: llAngleBetween returns NaN for some rotations when 0.0 is the expected answer | |||||||||
| Description | For 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 Reproduce | Create 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 Information | float 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)); } } | |||||||||
| Tags | No tags attached. | |||||||||
| Git Revision or version number | where do I git a git revision number? | |||||||||
| Run Mode | Grid (Multiple Regions per Sim) | |||||||||
| Physics Engine | ODE | |||||||||
| Environment | Unknown | |||||||||
| Mono Version | None | |||||||||
| Viewer | Doesn't matter, Phoenix o | |||||||||
| Attached Files | ||||||||||
Notes |
|
|
(0021929) SignpostMarv (reporter) 2012-07-28 21: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 16:36 | Kayaker Magic | New Issue | |
| 2012-07-28 21:33 | SignpostMarv | Note Added: 0021929 | |
| Copyright © 2000 - 2012 MantisBT Group |