Suggestion for improving quaternions
- Actually, quaternions
(x, y, z, w)and(-x, -y, -z, -w)represent the same rotations. If combine two quaternion for rotations by 180 degrees, you will get rotation by 360, represented as (0, 0, 0, -1). So may be worth to fixisFuzzyEqualor add methodisFussyEqualRotationsbecause quaternions not equal by components may correspond to the same rotations. - Quaternion has logarithm and exponent operations, connecting them to rotational axis. So
exp(axisNormalizedVector * angle) = quaternion, andlog(quaternion) = axisMultupliedByAngle. So if you want to interpolate or extrapolate rotation by value t, it is the most precise approach (linear interpolation is not that precise) - And each place with division has corner cases where could be either divizion by zero, either loss of precision.
I am author of one geometric algebra library in Scala, which I am using for physics simulation, and wrote some code accounting all corner cases. For example, logarithm of quaternion: https://github.com/Kright/ScalaGameMath/blob/master/pga3d/shared/src/main/scala/com/github/kright/pga3d/Pga3dQuaternion.scala#L119 And exponent of vector: https://github.com/Kright/ScalaGameMath/blob/master/pga3d/shared/src/main/scala/com/github/kright/pga3d/Pga3dBivectorBulk.scala#L161 And tests for this: https://github.com/Kright/ScalaGameMath/blob/master/pga3d/jvm/src/test/scala/com/github/kright/pga3d/BivectorExponentTest.scala#L23
If you interested in, I can make a pull request with fixes.
Hi, thanks for the suggestions!
If you could make a PR that would be very nice!