[Solved] Howto caculate the average rotation

How can I caculate the average rotation having for example three nodes?

can that be done directly with quaternions? or do I have to go with the rotation axis (just sum up and divide by 3)?

thanks a lot

What do you mean by average rotation having three nodes? You mean the resultant rotation?

Seems like a strange thing to need… can you explain why you want it to verify that we aren’t hitting an XY problem?

http://mywiki.wooledge.org/XyProblem

Ok more details: I want to simulate a flock swarm. So every agent which flies around has a ghost control (a sphere with a bigger radius than the agent itself has), so I can easily detect all my nearby agents. Hope so far it is clear.

Now I want to head my agent in the “avarage” direction of my neighbours. I think I just can sum up all x, y, z rotation and divide id by the number of neighbours.
But I saw with that this way I only fullfill one of the three rules you normaly need for flock swarm behavour. I suppose I have to go with a speed vector every agent stores and work with that to know where to move in this step.

But with the vector it do not look that sexy because the agent (currently a cube, but later it will be a cubeoid or something similar) do not “look” in the direction this vector points and I have no clue how I can make it look in the direction of the newly calculated vector.

I hope it is more clear now?

Average the direction vectors and then turn that into a rotation.

Anything else will cause you issues.

Sounds like you already have that direction anyway based on the rest of your message… so just look in that direction. Check the javadoc for “looking” in a direction… either on Quaternion’s javadoc or your Spatial’s javadoc depending on what you are using to “look at” that direction.

thanks a lot. that lookAt did finally what I wanted.