Merge pull request #185 from Holmqvist1990/master
Add `MatrixRotateXYZ`
This commit is contained in:
commit
2ba84634ed
1 changed files with 26 additions and 0 deletions
|
@ -653,6 +653,32 @@ func MatrixRotateZ(angle float32) Matrix {
|
|||
return result
|
||||
}
|
||||
|
||||
// MatrixRotateXYZ - Get xyz-rotation matrix (angles in radians)
|
||||
func MatrixRotateXYZ(ang Vector3) Matrix {
|
||||
result := MatrixIdentity()
|
||||
|
||||
cosz := float32(math.Cos(float64(-ang.Z)))
|
||||
sinz := float32(math.Sin(float64(-ang.Z)))
|
||||
cosy := float32(math.Cos(float64(-ang.Y)))
|
||||
siny := float32(math.Sin(float64(-ang.Y)))
|
||||
cosx := float32(math.Cos(float64(-ang.X)))
|
||||
sinx := float32(math.Sin(float64(-ang.X)))
|
||||
|
||||
result.M0 = cosz * cosy
|
||||
result.M4 = (cosz * siny * sinx) - (sinz * cosx)
|
||||
result.M8 = (cosz * siny * cosx) + (sinz * sinx)
|
||||
|
||||
result.M1 = sinz * cosy
|
||||
result.M5 = (sinz * siny * sinx) + (cosz * cosx)
|
||||
result.M9 = (sinz * siny * cosx) - (cosz * sinx)
|
||||
|
||||
result.M2 = -siny
|
||||
result.M6 = cosy * sinx
|
||||
result.M10 = cosy * cosx
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// MatrixScale - Returns scaling matrix
|
||||
func MatrixScale(x, y, z float32) Matrix {
|
||||
result := NewMatrix(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue