File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -117,8 +117,7 @@ public extension Position3n where Scalar: FloatingPoint {
117117 */
118118 @inlinable
119119 func rotated( around anchor: Self = . zero, by rotation: Rotation3n < Scalar > ) -> Self {
120- let d = self . distance ( from: anchor)
121- return anchor. moved ( d, toward: rotation. forward)
120+ fatalError ( " Not implemented " )
122121 }
123122
124123 /** Rotates `self` around an anchor position.
Original file line number Diff line number Diff line change @@ -157,8 +157,14 @@ public extension Position3 {
157157 */
158158 @inlinable
159159 func rotated( around anchor: Self = . zero, by rotation: Quaternion ) -> Self {
160+ #if false
161+ // TODO: This implementation is less accurate, needs testing to see if there's any performance benefits
160162 let d = self . distance ( from: anchor)
161- return anchor. moved ( d, toward: rotation. forward)
163+ let currentRotation = Quaternion ( direction: Direction3 ( from: anchor, to: self ) )
164+ return anchor. moved ( d, toward: ( rotation * currentRotation) . forward)
165+ #else
166+ return ( Matrix4x4 ( position: anchor) * Matrix4x4( rotation: rotation) ) * self
167+ #endif
162168 }
163169
164170 /** Rotates `self` around an anchor position.
You can’t perform that action at this time.
0 commit comments