Documentation ¶
Overview ¶
Package quaternion contains a float64 unit-quaternion type T and functions.
Index ¶
- Variables
- func Dot(a, b *T) float64
- func IsShortestRotation(a, b *T) bool
- type T
- func FromAxisAngle(axis *vec3.T, angle float64) T
- func FromEulerAngles(yHead, xPitch, zRoll float64) T
- func FromRotationAxes(xAxis, yAxis, zAxis vec3.T) T
- func FromVec4(v *vec4.T) T
- func FromXAxisAngle(angle float64) T
- func FromYAxisAngle(angle float64) T
- func FromZAxisAngle(angle float64) T
- func Mul(a, b *T) T
- func Mul3(a, b, c *T) T
- func Mul4(a, b, c, d *T) T
- func Parse(s string) (r T, err error)
- func Slerp(a, b *T, t float64) T
- func Vec3Diff(a, b *vec3.T) T
- func (quat *T) AxisAngle() (axis vec3.T, angle float64)
- func (quat *T) Invert() *T
- func (quat *T) Inverted() T
- func (quat *T) IsUnitQuat(tolerance float64) bool
- func (quat *T) Negate() *T
- func (quat *T) Negated() T
- func (quat *T) Norm() float64
- func (quat *T) Normalize() *T
- func (quat *T) Normalized() T
- func (quat *T) RotateVec3(v *vec3.T)
- func (quat *T) RotatedVec3(v *vec3.T) vec3.T
- func (quat *T) SetShortestRotation(other *T) *T
- func (q T) String() string
- func (q T) ToEuler() (rotX, rotY, rotZ float64)
- func (quat *T) Vec4() vec4.T
Constants ¶
This section is empty.
Variables ¶
var ( // Zero holds a zero quaternion. Zero = T{} // Ident holds an ident quaternion. Ident = T{0, 0, 0, 1} )
Functions ¶
func IsShortestRotation ¶
IsShortestRotation returns if the rotation from a to b is the shortest possible rotation. (there are two directions to rotate from the orientation of quat to the orientation of other) See T.SetShortestRotation
Types ¶
type T ¶
type T [4]float64 // [0, 1, 2, 3] => x, y, z, w
T represents a orientatin/rotation as a unit quaternion. See http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation
func FromAxisAngle ¶
FromAxisAngle returns a quaternion representing a rotation around an axis.
func FromEulerAngles ¶
FromEulerAngles returns a quaternion representing Euler angle rotations.
func FromRotationAxes ¶ added in v0.0.3
FromRotationAxes returns a quaternion from the columns of a 3x3 rotation matrix.
func FromXAxisAngle ¶
FromXAxisAngle returns a quaternion representing a rotation around the x axis.
func FromYAxisAngle ¶
FromYAxisAngle returns a quaternion representing a rotation around the y axis.
func FromZAxisAngle ¶
FromZAxisAngle returns a quaternion representing a rotation around the z axis.
func Slerp ¶
Slerp returns the spherical linear interpolation quaternion between a and b at t (0,1). See http://en.wikipedia.org/wiki/Slerp
func (*T) AxisAngle ¶
AxisAngle extracts the rotation from a normalized quaternion in the form of an axis and a rotation angle.
func (*T) IsUnitQuat ¶
IsUnitQuat returns if the quaternion is within tolerance of the unit quaternion.
func (*T) Normalized ¶
Normalized returns a copy normalized to a unit quaternation.
func (*T) RotateVec3 ¶
RotateVec3 rotates v by the rotation represented by the quaternion.
func (*T) RotatedVec3 ¶
RotatedVec3 returns a rotated copy of v.
func (*T) SetShortestRotation ¶
SetShortestRotation negates the quaternion if it does not represent the shortest rotation from quat to the orientation of other. (there are two directions to rotate from the orientation of quat to the orientation of other) See IsShortestRotation()