'From Squeak3.2gamma of 7 February 2002 [latest update: #4889] on 20 June 2002 at 1:17:09 am'! "Change Set: B3DRotationFix-jcg Date: 20 June 2002 Author: Joshua Gargus Before this fix, the following erroneous behavior was observed: (B3DRotation from: 0@0@1 to: 0@1@0) angle => 0.0 (B3DRotation from: 0@0@1 to: (0@1@1) normalized) angle => 180.0 This changeset fixes the problem, also addressing the special cases of rotating between parallel vectors with both the same and opposite orientations. "! !B3DRotation methodsFor: 'initialize' stamp: 'jcg 6/20/2002 01:13'! from: startVector to: endVector "Create a rotation from startVector to endVector. Vectors should be normalized first. Note: doesn't work when vectors are 180 degrees to each other." | axis cos sin | startVector = endVector ifTrue: [^ self setIdentity]. axis := startVector cross: endVector. cos := ((1 + (startVector dot: endVector)) / 2) sqrt. "half-angle relation" sin _ cos isZero ifTrue: [ "180 degree rotation" ^ self angle: 180 axis: (B3DVector3 perpendicularTo: startVector)] ifFalse: [axis length / 2 / cos]. "double angle relation" axis safelyNormalize. self a: cos b: axis x * sin c: axis y * sin d: axis z * sin. ! !