[
https://issues.apache.org/jira/browse/MATH-1634?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17433724#comment-17433724
]
Alex Herbert commented on MATH-1634:
------------------------------------
IIUC:
* The Rotation class from math3 represents the quaternion incorrectly but when
constructed using an axis and angle and applied to a vector produces the
correct result.
* The QuaternionRotation from geometry represents the quaternion correctly and
when applied to a vector produces the correct result.
This would indicate that constructing the QuaternionRotation in geometry from
the correct quaternion representation it would function as expected. Doing the
same in math3 would produce an invalid rotation.
So there is a bug in math3 but not geometry.
Note that geometry is the current development version for the entire
math3.geometry package (i.e. the geometry package is not present in the
development version of math4.) So this bug is fixed by converting code to use
the new geometry API.
{quote}having classes Vector3D in commons-math3 and in commons-geometry with
different definitions can be inconvenient for users.
{quote}
Agreed. But this should be a one time inconvenience experienced during upgrade.
The old Vector3D class exists under the math3.geometry package and it is not
expected to use this in parallel with the new geometry package. All future
usage of this class in current development version of Commons Math (math4)
would be via a dependency on the new geometry packages. This separation of
math3 (now math4) into smaller packages is an ongoing work.
Note also that the Quaternion class is in the Commons Numbers project. The
Geometry project depends on this project (see [Javadoc Commons Numbers
Quarternion|http://example.com/]).
> Quaternion representation of Rotation is incorrect
> --------------------------------------------------
>
> Key: MATH-1634
> URL: https://issues.apache.org/jira/browse/MATH-1634
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 3.6
> Reporter: Piotr Gutkowski
> Priority: Major
> Attachments: image-2021-10-22-13-12-53-900.png,
> image-2021-10-25-10-20-22-202.png
>
>
> Rotation is internally represented using quaternions. This representation is
> not correct in terms of quaternion values, though aparently the Rotation
> object behave correctly when it is constructed using angles or axes.
> For example, consider following rotation:
> Rotation r2 = {color:#000080}new {color}Rotation({color:#000080}new
> {color}Vector3D({color:#0000ff}0{color},{color:#0000ff}0{color},{color:#0000ff}1{color}),
> Math.{color:#660e7a}PI{color}/{color:#0000ff}2{color},
> {color:#660e7a}VECTOR_OPERATOR{color});
> It describes a counter-clockwise rotation around Z axis by 90 degrees,
> similar to the example given here:
> [https://commons.apache.org/proper/commons-math/javadocs/api-3.6/org/apache/commons/math3/geometry/euclidean/threed/RotationConvention.html#VECTOR_OPERATOR]
> Such rotation should transform vector (1,0,0) into (0,1,0).
> The values of quaternions for this rotation are:
> !image-2021-10-22-13-12-53-900.png!
> (recall that 0.7071 is approximately sqrt(2)/2)
> Performing the rotation using quaternion algebra, corresponds to:
> p = (1,0,0) = i
> f(p) = q p q^(1) = (q0 + q3*k)*i*(q0 - q3*k) = -j
> -j = (0, -1, 0)
> where, i, j, k are imaginary unit vectors corresponding to axes x,y,z
> respectively.
> You can visualize quaternions here:
> [https://eater.net/quaternions/video/intro]
> to see that in fact these quaternion values would produce rotation by - 90
> degrees around Z axis.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)