|
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
|
09-10-2007 18:22
I need what I think would normally be the average (mean) of two rotations.
Here's what I'm really doing. I have 3 points (locations for objects, links in a necklace, this is a necklace builder).
I can get a rotation that corresponds to the direction from p1 to p2, and another for p2 to p3. I want to get a rotation to apply to the object at p1 that's halfway between these two rotations.
I suppose I could do it in Euler, and I'll try that.
These quaternions are giving me a headache!
Thanks!
|
|
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
|
09-10-2007 18:46
Never mind, unless you have a sweet optimization. Euler method worked perfectly. One more compensation to figure out, stay tuned!
|
|
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
|
09-10-2007 22:43
Ah, if the two rotations have the same axis then yeah (unless they are rotations by angles that differ by 180 degrees), but does it make sense to talk about a rotation midway between two given rotations in general? What would it mean?
_____________________
-Seifert Surface 2G!tGLf 2nLt9cG
|
|
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
|
09-10-2007 23:33
I never really work in quaternions, work in Euler vectors, and simply convert to quaternions, then perform the rotation...
vector CalculatedVector <1,2,3>; CalculatedVector *= DEG_TO_RAD; rotation quat = llEuler2Rot(CalculatedVector); llSetRot(quat);
|
|
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
|
09-11-2007 15:59
From: Seifert Surface Ah, if the two rotations have the same axis then yeah (unless they are rotations by angles that differ by 180 degrees), but does it make sense to talk about a rotation midway between two given rotations in general? What would it mean? It means the same thing, and it works fine. The rotation is in all 3 dimensions in my case. Imagine a dot on the surface of a sphere. Rotate the sphere in any number of angles and now look at where the dot is. If you bisect the sphere with a plane that intersects both spots (original and new dot position), the intersection of the plane and the sphere is a great circle on the sphere, and represents the shortest path on the surface between the two points. What I needed is the rotation corresponding to the dot winding up halfway along that great circle path between the two points. This is for a necklace generator. I already had a script that plots the saddle shape for any number of points (links). Next I wanted to get the rotation for each prim, based on the two neighboring prim locations. It's working like a charm for simple prims like cubes, where the position of the cube is the position of the true center. Next adjustment is to compensate for links whose position-centers are off-center due to prim torture. A new thread for that! Thanks folks 
|
|
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
|
09-11-2007 17:50
I was curious about this so googled a bit.. try this out: rotation rotMean(rotation a, rotation b) { rotation tempRot = b/a; tempRot += <0, 0, 0, 1.0>; float mag = llSqrt( tempRot.s*tempRot.s + tempRot.x*tempRot.x + tempRot.y*tempRot.y + tempRot.z*tempRot.z); tempRot = <tempRot.x/mag, tempRot.y/mag, tempRot.z/mag, tempRot.s/mag>;
return a * tempRot; }
|
|
Carnie Bing
Registered User
Join date: 19 Feb 2007
Posts: 1
|
Interpolating orientations
09-12-2007 08:18
Should be done by an interpolation that keeps the rotation on the surface of a sphere. This is done with a Spherical Linear Interpolation (see http://en.wikipedia.org/wiki/Slerp).
|