[ https://issues.apache.org/jira/browse/MATH-1634?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17433623#comment-17433623 ]
Piotr Gutkowski commented on MATH-1634: --------------------------------------- I checked QuaternionRotation class, and it seems to have correct representation: !image-2021-10-25-10-20-22-202.png! Application of such defined QuaternionRotation to vector (1,0,0) gives the same result (0,1,0) as application of Rotation object, so from rotation perspective both classes behave correctly. It is only the quaternion representation of Rotation class that is incorrect. Please notice, that when constructing Rotation object from math3, there is additional degree of freedom - the RotationConvention, which is not present for QuaternionRotation. I would like also to point out, that having classes Vector3D in commons-math3 and in commons-geometry with different definitions can be inconvenient for users. Probably you should unify this, and other duplicated classes, so that they could be used in both libraries. > 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)