|
Hi, Quaternion.Angle returns the absolute angle between two transform.rotation. Is there a technic to get it signed, I am currently using cross products and vector comparison to check. It seems to me very cumbersome. Is there a better technic or something built in actually? Thanks for your help, Jean
(comments are locked)
|
|
To get the unsigned angle between two quaternions, you can use the Quaternion.Angle function:
However to get a signed angle doesn't really make a lot of sense in 3D space, because the rotation could be in any 3d direction (not just in one of two 'flat' directions). Unity does however provide the function "Mathf.DeltaAngle" to get the signed difference between two angles (not rotations), so perhaps what you want to do is convert your 3D rotations into 2D angles relative to a certain direction on a certain plane (using Atan2). For example, to compare the angle of rotationA with rotationB, projected on the X-Z plane, you could do this:
Angle differences on the X-Z plane would be suitable for "top down" angle differences - eg, determining the directional differences between cars on a terrain. For other situations, you might need to use a different plane such as X-Y or Y-Z. Hope this solves your problem! Thanks Duck, yes, signed angle make sense only against a plane or an axis, that's what I am am after. The code is as involving as is mine currently.
Sep 07 '10 at 12:05 PM
Jean Fabre
I love you. Seriously, thanks a lot!
Dec 30 '12 at 09:07 PM
Saturnix
(comments are locked)
|
