Azelda Garcia
Azelda Garcia
Join date: 3 Nov 2003
Posts: 819
|
01-06-2004 18:31
(ok, so what is happening conretely I think is: to get the rotation axis, the algo is most likely doing a crossproduct of the two vectors, then normalizing it. Crossproducts is linear with sin theta, where theta is angle between vectors, and so is *zero* for theta=180. If the vector is zero, then the mod is zero, so when you try to normalize (divide by mod), you get a math error
Basically, the fact that the cross product is zero is a way of saying mathematically that there are an infinite number of vectors perpendicular to two parallel vectors
I assume that the case vectorone == vectortwo is already treated as an exception so that leaves just the case where they are opposite )
|
Mark Busch
DarkLife Developer
Join date: 8 Apr 2003
Posts: 442
|
01-07-2004 16:29
I emailed Cory Linden with script that caused the error. This was the response:
"Found it. llRotBetween could cause a divide by zero. This is fixed and will be deployed with our next release."
Thanks Cory!
Great work on finding the bug Azelda, but you don't need the work around anymore in the next version, it's fixed.
|
Kex Godel
Master Slacker
Join date: 14 Nov 2003
Posts: 869
|
01-08-2004 08:25
From: someone Originally posted by Azelda Garcia Yeah, the problem is basically caused by trying to get the rotation between two opposite directions, and the algo cant work out which axis to rotate around.
For example, to get from <1,0,0> to <-1,0,0> you can either rotate about the z axis, or about the y-axis: you end up pointing in the same final direction, but in one the object will be rotated about the x-axis compared to the other.
I thought the whole purpose of having quaternions was to avoid these kinds of issues with rotation?...
|
Azelda Garcia
Azelda Garcia
Join date: 3 Nov 2003
Posts: 819
|
01-08-2004 09:37
> I thought the whole purpose of having quaternions was to avoid these kinds of issues with rotation?... RotBetween takes two vectors as arguments. There's no trivial way around the problem because the vectors youre doing RotBetween arent actually rotations. So you couldnt do for example Inverse(AxisAngle2Rot(VectorOne, 0) ) * AxisAngle2Rot( VectorTwo, 0 ), because both AxisAngle2Rots will simply return the equivalent of ZERO_ROTATION so the whole thing will return ZERO_ROTATION. RotBetween is one of the major ways to generate a rotation. Typically, you would use it as follows (which is why both Mark and I got this bug): vector FwdVector = < 1, 0, 0 >;
vector VectorToTarget = llDetectedPos(i) - llGetPos; vector PlanarVectorToTarget = < VectorToTarget.x, VectorToTarget.y, 0 >;
llSetRot( llRotBetween( FwdVector, PlanarVectorToTarget ) );
Obviously, the moment you stand directly to West of the mob, boom! Math error. Azelda
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
01-12-2004 17:17
Bump! This has fallen off the front page 
|