Improved accuracy of Quaternion::Normalize
This commit is contained in:
parent
5c11ba83fd
commit
adb9b6e235
@ -58,20 +58,21 @@ float Quaternion::GetLengthSquared(const Quaternion& q) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Quaternion::Normalize() {
|
void Quaternion::Normalize() {
|
||||||
float scale = 1.0f / GetLength();
|
float length = GetLength();
|
||||||
x *= scale;
|
x /= length;
|
||||||
y *= scale;
|
y /= length;
|
||||||
z *= scale;
|
z /= length;
|
||||||
w *= scale;
|
w /= length;
|
||||||
}
|
}
|
||||||
|
|
||||||
Quaternion Quaternion::Normalize(const Quaternion& q) {
|
Quaternion Quaternion::Normalize(const Quaternion& q) {
|
||||||
Quaternion result;
|
Quaternion result;
|
||||||
float scale = 1.0f / q.GetLength();
|
float length = q.GetLength();
|
||||||
result = Quaternion(q.x * scale, q.y * scale, q.z * scale, q.w * scale);
|
result = Quaternion(q.x / length, q.y / length, q.z / length, q.w / length);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
float Quaternion::Dot(Quaternion a, Quaternion b) {
|
float Quaternion::Dot(Quaternion a, Quaternion b) {
|
||||||
return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
|
return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user