示例#1
0
文件: quat.go 项目: void6/lm
func QuatAxisRotation(axis Vec3, angle float32) Quat {
	var d = 1 / axis.Len()
	halfAngle := angle / 2.0
	s := math32.Sin(halfAngle)
	c := math32.Cos(halfAngle)
	return Quat{s * axis[0] * d, s * axis[1] * d, s * axis[2] * d, c}
}
示例#2
0
文件: mat3x3.go 项目: void6/lm
func Mat3x3Rotate(radians float32) Mat3x3 {
	c := math32.Cos(radians)
	s := math32.Sin(radians)
	return Mat3x3{
		s, -c, 0,
		c, s, 0,
		0, 0, 1}
}
示例#3
0
文件: mat4x4.go 项目: void6/lm
func Mat4x4Rotate(axis Vec3, radians float32) Mat4x4 {
	x, y, z := axis.Norm().XYZ()
	c := math32.Cos(radians)
	s := math32.Sin(radians)

	return Mat4x4{
		x*x*(1-c) + c, y*x*(1-c) + z*s, x*z*(1-c) - y*s, 0,
		x*y*(1-c) - z*s, y*y*(1-c) + c, y*z*(1-c) + x*s, 0,
		x*z*(1-c) + y*s, y*z*(1-c) - x*s, z*z*(1-c) + c, 0,
		0, 0, 0, 1}
}