@@ -103,40 +103,7 @@ public float this[int index]
103
103
/// <remarks>The <see cref="op_Division" /> method defines the division operation for <see cref="Quaternion" /> objects.</remarks>
104
104
public static Quaternion operator / ( Quaternion value1 , Quaternion value2 )
105
105
{
106
- Quaternion ans ;
107
-
108
- float q1x = value1 . X ;
109
- float q1y = value1 . Y ;
110
- float q1z = value1 . Z ;
111
- float q1w = value1 . W ;
112
-
113
- //-------------------------------------
114
- // Inverse part.
115
- float ls = value2 . X * value2 . X + value2 . Y * value2 . Y +
116
- value2 . Z * value2 . Z + value2 . W * value2 . W ;
117
- float invNorm = 1.0f / ls ;
118
-
119
- float q2x = - value2 . X * invNorm ;
120
- float q2y = - value2 . Y * invNorm ;
121
- float q2z = - value2 . Z * invNorm ;
122
- float q2w = value2 . W * invNorm ;
123
-
124
- //-------------------------------------
125
- // Multiply part.
126
-
127
- // cross(av, bv)
128
- float cx = q1y * q2z - q1z * q2y ;
129
- float cy = q1z * q2x - q1x * q2z ;
130
- float cz = q1x * q2y - q1y * q2x ;
131
-
132
- float dot = q1x * q2x + q1y * q2y + q1z * q2z ;
133
-
134
- ans . X = q1x * q2w + q2x * q1w + cx ;
135
- ans . Y = q1y * q2w + q2y * q1w + cy ;
136
- ans . Z = q1z * q2w + q2z * q1w + cz ;
137
- ans . W = q1w * q2w - dot ;
138
-
139
- return ans ;
106
+ return value1 * Inverse ( value2 ) ;
140
107
}
141
108
142
109
/// <summary>Returns a value that indicates whether two quaternions are equal.</summary>
@@ -169,6 +136,7 @@ public float this[int index]
169
136
Vector128 < float > right = value2 . AsVector128 ( ) ;
170
137
171
138
Vector128 < float > result = right * left . GetElementUnsafe ( 3 ) ;
139
+
172
140
result += ( Vector128 . Shuffle ( right , Vector128 . Create ( 3 , 2 , 1 , 0 ) ) * left . GetElementUnsafe ( 0 ) ) * Vector128 . Create ( + 1.0f , - 1.0f , + 1.0f , - 1.0f ) ;
173
141
result += ( Vector128 . Shuffle ( right , Vector128 . Create ( 2 , 3 , 0 , 1 ) ) * left . GetElementUnsafe ( 1 ) ) * Vector128 . Create ( + 1.0f , + 1.0f , - 1.0f , - 1.0f ) ;
174
142
result += ( Vector128 . Shuffle ( right , Vector128 . Create ( 1 , 0 , 3 , 2 ) ) * left . GetElementUnsafe ( 2 ) ) * Vector128 . Create ( - 1.0f , + 1.0f , + 1.0f , - 1.0f ) ;
@@ -241,36 +209,7 @@ public float this[int index]
241
209
/// <param name="value1">The first quaternion rotation in the series.</param>
242
210
/// <param name="value2">The second quaternion rotation in the series.</param>
243
211
/// <returns>A new quaternion representing the concatenation of the <paramref name="value1" /> rotation followed by the <paramref name="value2" /> rotation.</returns>
244
- public static Quaternion Concatenate ( Quaternion value1 , Quaternion value2 )
245
- {
246
- Quaternion ans ;
247
-
248
- // Concatenate rotation is actually q2 * q1 instead of q1 * q2.
249
- // So that's why value2 goes q1 and value1 goes q2.
250
- float q1x = value2 . X ;
251
- float q1y = value2 . Y ;
252
- float q1z = value2 . Z ;
253
- float q1w = value2 . W ;
254
-
255
- float q2x = value1 . X ;
256
- float q2y = value1 . Y ;
257
- float q2z = value1 . Z ;
258
- float q2w = value1 . W ;
259
-
260
- // cross(av, bv)
261
- float cx = q1y * q2z - q1z * q2y ;
262
- float cy = q1z * q2x - q1x * q2z ;
263
- float cz = q1x * q2y - q1y * q2x ;
264
-
265
- float dot = q1x * q2x + q1y * q2y + q1z * q2z ;
266
-
267
- ans . X = q1x * q2w + q2x * q1w + cx ;
268
- ans . Y = q1y * q2w + q2y * q1w + cy ;
269
- ans . Z = q1z * q2w + q2z * q1w + cz ;
270
- ans . W = q1w * q2w - dot ;
271
-
272
- return ans ;
273
- }
212
+ public static Quaternion Concatenate ( Quaternion value1 , Quaternion value2 ) => value2 * value1 ;
274
213
275
214
/// <summary>Returns the conjugate of a specified quaternion.</summary>
276
215
/// <param name="value">The quaternion.</param>
0 commit comments