Documentation
¶
Index ¶
- Constants
- Variables
- type Dual
- func (lhs Dual) Add(rhs Dual) Dual
- func (dq Dual) Conjugate() Dual
- func (lhs Dual) Dot(rhs Dual) float64
- func (lhs Dual) Equal(rhs Dual) bool
- func (dq Dual) Matrix() matrix.Matrix
- func (lhs Dual) Mul(rhs Dual) Dual
- func (dq Dual) Normalize() Dual
- func (dq Dual) Rotate(r Quat) Dual
- func (dq Dual) Rotation() Quat
- func (dq Dual) Scale(scale float64) Dual
- func (dq Dual) String() string
- func (dq Dual) Transform(x, y, z float64) (float64, float64, float64)
- func (dq Dual) Translate(tx, ty, tz float64) Dual
- func (dq Dual) Translation() (x, y, z float64)
- type Quat
- func (lhs Quat) Add(rhs Quat) Quat
- func (q Quat) Conjugate() Quat
- func (lhs Quat) Dot(rhs Quat) float64
- func (lhs Quat) Equal(rhs Quat) bool
- func (q Quat) Length() float64
- func (q Quat) Matrix() matrix.Matrix
- func (lhs Quat) Mul(rhs Quat) Quat
- func (q Quat) Normalize() Quat
- func (q Quat) RotX(angle float64) Quat
- func (q Quat) RotY(angle float64) Quat
- func (q Quat) RotZ(angle float64) Quat
- func (q Quat) Scale(scale float64) Quat
- func (q Quat) String() string
- func (q Quat) Transform(vx, vy, vz float64) (x, y, z float64)
Constants ¶
const PixelsPerRadian = 150
Variables ¶
var DualIdentity = Dual{Real: Identity}
DualIdentity returns the Dual Quaternion that induces zero translation and zero rotation when multiplied with another Dual Quaternion.
var Identity = Quat{0, 0, 0, 1}
Identity is the Identity quaternion
Functions ¶
This section is empty.
Types ¶
type Dual ¶
type Dual struct{ Real, Dual Quat }
Dual is a concatenated Translation*Rotation. A point transformed with it, first has rotation applied and then translation. This behavior is identical to the order a homogenous matrix would perform the operation.
func (Dual) Matrix ¶
Matrix will return a matrix with 4 rows and 4 columns, the top left 3x3 matrix contains the rotation and the top right 3x1 vector contains the translation. It takes 38 muls, 28 adds to derive a homogenous matrix from the dual quaternion.
func (Dual) Mul ¶
Mul multiplies two dual quaternions. Uses 3 quaternion muls and 1 quaternion add. In total this uses 48 muls and 40 adds.
func (Dual) Transform ¶
Transform will transform a vector in the space described by the dual quaternion and transform that into the parent space. This takes 37 muls, 27 adds. By comparison a homogenous matrix transform takes 9 muls and 9 adds but needs to have the Matrix extracted first.
func (Dual) Translation ¶
Translation will extract the translation vector from the Dual quaternion. To extract the translation 19 muls, 12 adds are needed
type Quat ¶
type Quat struct {
X, Y, Z, W float64
}
Quat is used for computing quaterion multiplications. This creates more natural mouse rotations.
Attribution: adapted from http://glprogramming.com/codedump/godecho/quaternion.html
func AxisAngle ¶
AxisAngle returns a quaternion representing a rotation about an axis. The axis is defined by the vector (x, y, z) and the rotation angle is specified in radians. If the axis vector is zero, the function returns the Identity quaternion.
func (Quat) Dot ¶
Dot returns the quaternion dot product (inner product) of the target (q) and r. (For two normalized quaternions, this will be 1 if they’re equal, -1 if they’re opposite and 0 if they’re perpendicular.)
func (Quat) Matrix ¶
Matrix will return a matrix with 4 rows and 4 columns, the top left 3x3 matrix contains the rotation. Computing the 4x4 homogeneous matrix from the quaternion takes 18 muls and 12 adds
func (Quat) Mul ¶
Mul calculates the Hamilton product of two quaternions. This can be seen as a rotation. Note that Multiplication is NOT commutative, meaning q1.Mul(q2) does not necessarily equal q2.Mul(q1). This operation takes 16 muls and 12 adds or an alternative implemnentation can do it in 9 muls and 27 adds. It's not known whether adds on modern x86 cpu's are still faster than muls.