コード例 #1
0
ファイル: quaternion.go プロジェクト: pyros2097/spike
// Get the pitch euler angle in radians, which is the rotation around the x axis. Requires that this quaternion is normalized.
// return the rotation around the x axis in radians (between -(PI/2) and +(PI/2))
func (self *Quaternion) GetPitchRad() float32 {
	pole := self.GetGimbalPole()
	if pole == 0 {
		return float32(math.Asin(float64(utils.ClampFloat32(2*(self.w*self.x-self.z*self.y), -1, 1))))
	}
	return float32(pole) * utils.PI * 0.5
}
コード例 #2
0
ファイル: quaternion.go プロジェクト: pyros2097/spike
// Get the angle in radians of the rotation around the specified axis. The axis must be normalized.
// param axisX the x component of the normalized axis for which to get the angle
// param axisY the y component of the normalized axis for which to get the angle
// param axisZ the z component of the normalized axis for which to get the angle
// return the angle in radians of the rotation around the specified axis
func (self *Quaternion) GetAngleAroundRad(axisX, axisY, axisZ float32) float32 {
	d := DotV3(self.x, self.y, self.z, axisX, axisY, axisZ)
	l2 := Len2Q(axisX*d, axisY*d, axisZ*d, self.w)
	if utils.IsZero(l2) {
		return 0
	} else {
		return float32((2.0 * math.Acos(float64(utils.ClampFloat32((self.w/float32(math.Sqrt(float64(l2)))), -1, 1)))))
	}
}
コード例 #3
0
ファイル: main.go プロジェクト: pyros2097/spike
func Fade() Interpolation {
	return func(a float32) float32 {
		utils.ClampFloat32(a*a*a*(a*(a*6-15)+10), 0, 1)
		return a
	}
}
コード例 #4
0
ファイル: quaternion.go プロジェクト: pyros2097/spike
// Set this quaternion to the rotation between two vectors.
// param x1 The base vectors x value, which should be normalized.
// param y1 The base vectors y value, which should be normalized.
// param z1 The base vectors z value, which should be normalized.
// param x2 The target vector x value, which should be normalized.
// param y2 The target vector y value, which should be normalized.
// param z2 The target vector z value, which should be normalized.
func (self *Quaternion) SetFromCross(x1, y1, z1, x2, y2, z2 float32) *Quaternion {
	dot := utils.ClampFloat32(DotV3(x1, y1, z1, x2, y2, z2), -1, 1)
	angle := float32(math.Acos(float64(dot)))
	return self.SetFromAxisRad(y1*z2-z1*y2, z1*x2-x1*z2, x1*y2-y1*x2, angle)
}
コード例 #5
0
ファイル: quaternion.go プロジェクト: pyros2097/spike
// Set this quaternion to the rotation between two vectors.
// param v1 The base vector, which should be normalized.
// param v2 The target vector, which should be normalized.
func (self *Quaternion) SetFromCrossV3(v1, v2 *Vector3) *Quaternion {
	dot := utils.ClampFloat32(v1.DotV(v2), -1, 1)
	angle := float32(math.Acos(float64(dot)))
	return self.SetFromAxisRad(v1.Y*v2.Z-v1.Z*v2.Y, v1.Z*v2.X-v1.X*v2.Z, v1.X*v2.Y-v1.Y*v2.X, angle)
}