fixed QuaternionNormalize
This commit is contained in:
parent
99078f2467
commit
3af420ddc4
1 changed files with 7 additions and 13 deletions
|
@ -793,23 +793,17 @@ func QuaternionLength(quat Quaternion) float32 {
|
||||||
|
|
||||||
// QuaternionNormalize - Normalize provided quaternion
|
// QuaternionNormalize - Normalize provided quaternion
|
||||||
func QuaternionNormalize(q Quaternion) Quaternion {
|
func QuaternionNormalize(q Quaternion) Quaternion {
|
||||||
var result Quaternion
|
result := q
|
||||||
|
|
||||||
var length, ilength float32
|
length := QuaternionLength(q)
|
||||||
|
|
||||||
length = QuaternionLength(q)
|
if length != 0.0 {
|
||||||
|
result.X /= length
|
||||||
if length == 0.0 {
|
result.Y /= length
|
||||||
length = 1.0
|
result.Z /= length
|
||||||
|
result.W /= length
|
||||||
}
|
}
|
||||||
|
|
||||||
ilength = 1.0 / length
|
|
||||||
|
|
||||||
result.X *= ilength
|
|
||||||
result.Y *= ilength
|
|
||||||
result.Z *= ilength
|
|
||||||
result.W *= ilength
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue