Documentation
¶
Overview ¶
Package spatialmath defines spatial mathematical operations. Poses represent a position in 6 degrees of freedom, i.e. a position and an orientation. Positions are represented as r3 Vectors, while Orientations are an interface able to be represented many different ways. This package provides various Orientation implementations as well as the ability to perform a variety of useful operations on Poses and Orientations.
Index ¶
- Constants
- Variables
- func Flip(q quat.Number) quat.Number
- func Norm(q quat.Number) float64
- func Normalize(q quat.Number) quat.Number
- func OffsetBy(a, b *commonpb.Pose) *commonpb.Pose
- func OrientationAlmostEqual(o1, o2 Orientation) bool
- func OrientationAlmostEqualEps(o1, o2 Orientation, epsilon float64) bool
- func PoseAlmostCoincident(a, b Pose) bool
- func PoseAlmostCoincidentEps(a, b Pose, epsilon float64) bool
- func PoseAlmostEqual(a, b Pose) bool
- func PoseAlmostEqualEps(a, b Pose, epsilon float64) bool
- func PoseMap(p Pose) (map[string]interface{}, error)
- func PoseToProtobuf(p Pose) *commonpb.Pose
- func QuatToR3AA(q quat.Number) r3.Vector
- func QuaternionAlmostEqual(a, b quat.Number, tol float64) bool
- func R3VectorAlmostEqual(a, b r3.Vector, epsilon float64) bool
- func ResetPoseDQTranslation(p Pose, v r3.Vector)
- type AngularVelocity
- type AxisConfig
- type EulerAngles
- func (ea *EulerAngles) AxisAngles() *R4AA
- func (ea *EulerAngles) EulerAngles() *EulerAngles
- func (ea *EulerAngles) OrientationVectorDegrees() *OrientationVectorDegrees
- func (ea *EulerAngles) OrientationVectorRadians() *OrientationVector
- func (ea *EulerAngles) Quaternion() quat.Number
- func (ea *EulerAngles) RotationMatrix() *RotationMatrix
- type Geometry
- type GeometryConfig
- type GeometryType
- type Orientation
- type OrientationConfig
- type OrientationType
- type OrientationVector
- func (ov *OrientationVector) AxisAngles() *R4AA
- func (ov *OrientationVector) Degrees() *OrientationVectorDegrees
- func (ov *OrientationVector) EulerAngles() *EulerAngles
- func (ov *OrientationVector) IsValid() error
- func (ov *OrientationVector) Normalize()
- func (ov *OrientationVector) OrientationVectorDegrees() *OrientationVectorDegrees
- func (ov *OrientationVector) OrientationVectorRadians() *OrientationVector
- func (ov *OrientationVector) Quaternion() quat.Number
- func (ov *OrientationVector) RotationMatrix() *RotationMatrix
- func (ov *OrientationVector) ToQuat() quat.Number
- type OrientationVectorDegrees
- func (ovd *OrientationVectorDegrees) AxisAngles() *R4AA
- func (ovd *OrientationVectorDegrees) EulerAngles() *EulerAngles
- func (ovd *OrientationVectorDegrees) IsValid() error
- func (ovd *OrientationVectorDegrees) Normalize()
- func (ovd *OrientationVectorDegrees) OrientationVectorDegrees() *OrientationVectorDegrees
- func (ovd *OrientationVectorDegrees) OrientationVectorRadians() *OrientationVector
- func (ovd *OrientationVectorDegrees) Quaternion() quat.Number
- func (ovd *OrientationVectorDegrees) Radians() *OrientationVector
- func (ovd *OrientationVectorDegrees) RotationMatrix() *RotationMatrix
- func (ovd *OrientationVectorDegrees) ToQuat() quat.Number
- type Pose
- func Compose(a, b Pose) Pose
- func Interpolate(p1, p2 Pose, by float64) Pose
- func NewPose(p r3.Vector, o Orientation) Pose
- func NewPoseFromDH(a, d, alpha float64) Pose
- func NewPoseFromOrientation(o Orientation) Pose
- func NewPoseFromPoint(point r3.Vector) Pose
- func NewPoseFromProtobuf(pos *commonpb.Pose) Pose
- func NewZeroPose() Pose
- func PoseBetween(a, b Pose) Pose
- func PoseDelta(a, b Pose) Pose
- func PoseInverse(p Pose) Pose
- type Quaternion
- func (q *Quaternion) AxisAngles() *R4AA
- func (q *Quaternion) EulerAngles() *EulerAngles
- func (q *Quaternion) MarshalJSON() ([]byte, error)
- func (q *Quaternion) OrientationVectorDegrees() *OrientationVectorDegrees
- func (q *Quaternion) OrientationVectorRadians() *OrientationVector
- func (q *Quaternion) Quaternion() quat.Number
- func (q *Quaternion) RotationMatrix() *RotationMatrix
- type R4AA
- func (r4 *R4AA) AxisAngles() *R4AA
- func (r4 *R4AA) EulerAngles() *EulerAngles
- func (r4 *R4AA) Normalize()
- func (r4 *R4AA) OrientationVectorDegrees() *OrientationVectorDegrees
- func (r4 *R4AA) OrientationVectorRadians() *OrientationVector
- func (r4 *R4AA) Quaternion() quat.Number
- func (r4 *R4AA) RotationMatrix() *RotationMatrix
- func (r4 *R4AA) ToQuat() quat.Number
- func (r4 *R4AA) ToR3() r3.Vector
- type RotationMatrix
- func (rm *RotationMatrix) At(row, col int) float64
- func (rm *RotationMatrix) AxisAngles() *R4AA
- func (rm *RotationMatrix) Col(col int) r3.Vector
- func (rm *RotationMatrix) EulerAngles() *EulerAngles
- func (rm *RotationMatrix) LeftMatMul(lmm RotationMatrix) *RotationMatrix
- func (rm *RotationMatrix) Mul(v r3.Vector) r3.Vector
- func (rm *RotationMatrix) OrientationVectorDegrees() *OrientationVectorDegrees
- func (rm *RotationMatrix) OrientationVectorRadians() *OrientationVector
- func (rm *RotationMatrix) Quaternion() quat.Number
- func (rm *RotationMatrix) RightMatMul(rmm RotationMatrix) *RotationMatrix
- func (rm *RotationMatrix) RotationMatrix() *RotationMatrix
- func (rm *RotationMatrix) Row(row int) r3.Vector
Constants ¶
const ( UnknownType = GeometryType("") BoxType = GeometryType("box") SphereType = GeometryType("sphere") PointType = GeometryType("point") CollisionBuffer = 1e-8 // objects must be separated by this many mm to not be in collision )
The set of allowed representations for orientation.
const ( NoOrientationType = OrientationType("") OrientationVectorDegreesType = OrientationType("ov_degrees") OrientationVectorRadiansType = OrientationType("ov_radians") EulerAnglesType = OrientationType("euler_angles") AxisAnglesType = OrientationType("axis_angles") QuaternionType = OrientationType("quaternion") )
The set of allowed representations for orientation.
Variables ¶
var ErrGeometryTypeUnsupported = errors.New("unsupported Geometry type")
ErrGeometryTypeUnsupported is an error that is returned when an unsupported GeometryType is specified (either implicitly or explicitly) in a GeometryConfig.
Functions ¶
func Flip ¶
Flip will multiply a quaternion by -1, returning a quaternion representing the same orientation but in the opposing octant.
func Norm ¶
Norm returns the norm of the quaternion, i.e. the sqrt of the sum of the squares of the imaginary parts.
func OrientationAlmostEqual ¶
func OrientationAlmostEqual(o1, o2 Orientation) bool
OrientationAlmostEqual will return a bool describing whether 2 poses have approximately the same orientation.
func OrientationAlmostEqualEps ¶ added in v0.2.1
func OrientationAlmostEqualEps(o1, o2 Orientation, epsilon float64) bool
OrientationAlmostEqualEps will return a bool describing whether 2 poses have approximately the same orientation.
func PoseAlmostCoincident ¶
PoseAlmostCoincident will return a bool describing whether 2 poses approximately are at the same 3D coordinate location. This uses the same epsilon as the default value for the Viam IK solver.
func PoseAlmostCoincidentEps ¶
PoseAlmostCoincidentEps will return a bool describing whether 2 poses approximately are at the same 3D coordinate location. This uses a passed in epsilon value.
func PoseAlmostEqual ¶
PoseAlmostEqual will return a bool describing whether 2 poses are approximately the same.
func PoseAlmostEqualEps ¶ added in v0.2.1
PoseAlmostEqualEps will return a bool describing whether 2 poses are approximately the same.
func PoseMap ¶
PoseMap encodes the orientation interface to something serializable and human readable.
func PoseToProtobuf ¶
PoseToProtobuf converts a pose to the pose format protobuf expects (which is as OrientationVectorDegrees).
func QuatToR3AA ¶
QuatToR3AA converts a quat to an R3 axis angle in the same way the C++ Eigen library does. https://eigen.tuxfamily.org/dox/AngleAxis_8h_source.html
func QuaternionAlmostEqual ¶
QuaternionAlmostEqual is an equality test for all the float components of a quaternion. Quaternions have double coverage, q == -q, and this function will *not* account for this. Use OrientationAlmostEqual unless you're certain this is what you want.
func R3VectorAlmostEqual ¶
R3VectorAlmostEqual compares two r3.Vector objects and returns if the all elementwise differences are less than epsilon.
func ResetPoseDQTranslation ¶ added in v0.1.2
ResetPoseDQTranslation takes a Pose that must be a dualQuaternion and reset's it's translation.
Types ¶
type AngularVelocity ¶
AngularVelocity contains angular velocity in deg/s across x/y/z axes.
func EulerToAngVel ¶ added in v0.1.2
func EulerToAngVel(diffEu EulerAngles, dt float64) AngularVelocity
EulerToAngVel calculates an angular velocity based on an orientation change expressed in euler angles over a time differnce.
func OrientationToAngularVel ¶ added in v0.1.2
func OrientationToAngularVel(diff Orientation, dt float64) AngularVelocity
OrientationToAngularVel calculates an angular velocity based on an orientation change over a time differnce.
func PointAngVel ¶ added in v0.1.2
func PointAngVel(r, v r3.Vector) AngularVelocity
PointAngVel returns the angular velocity using the defiition r X v / |r|.
func R3ToAngVel ¶ added in v0.1.2
func R3ToAngVel(vec r3.Vector) *AngularVelocity
R3ToAngVel converts an r3Vector to an angular velocity.
func (*AngularVelocity) MulAngVel ¶ added in v0.1.2
func (av *AngularVelocity) MulAngVel(t float64) AngularVelocity
MulAngVel scales the angular velocity by a single scalar value.
type AxisConfig ¶
AxisConfig represents the configuration format representing an axis.
func NewAxisConfig ¶
func NewAxisConfig(axis R4AA) *AxisConfig
NewAxisConfig constructs a config from an R4AA.
func (AxisConfig) ParseConfig ¶
func (a AxisConfig) ParseConfig() R4AA
ParseConfig converts an AxisConfig into an R4AA object.
type EulerAngles ¶
type EulerAngles struct { Roll float64 `json:"roll"` // phi, X Pitch float64 `json:"pitch"` // theta, Y Yaw float64 `json:"yaw"` // psi, Z }
EulerAngles are three angles (in radians) used to represent the rotation of an object in 3D Euclidean space The Tait–Bryan angle formalism is used, with rotations around three distinct axes in the z-y′-x″ sequence.
func NewEulerAngles ¶
func NewEulerAngles() *EulerAngles
NewEulerAngles creates an empty EulerAngles struct.
func QuatToEulerAngles ¶
func QuatToEulerAngles(q quat.Number) *EulerAngles
QuatToEulerAngles converts a quaternion to the euler angle representation. Algorithm from Wikipedia. https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles#Quaternion_to_Euler_angles_conversion
func (*EulerAngles) AxisAngles ¶
func (ea *EulerAngles) AxisAngles() *R4AA
AxisAngles returns the orientation in axis angle representation.
func (*EulerAngles) EulerAngles ¶
func (ea *EulerAngles) EulerAngles() *EulerAngles
EulerAngles returns orientation in Euler angle representation.
func (*EulerAngles) OrientationVectorDegrees ¶
func (ea *EulerAngles) OrientationVectorDegrees() *OrientationVectorDegrees
OrientationVectorDegrees returns orientation as an orientation vector (in degrees).
func (*EulerAngles) OrientationVectorRadians ¶
func (ea *EulerAngles) OrientationVectorRadians() *OrientationVector
OrientationVectorRadians returns orientation as an orientation vector (in radians).
func (*EulerAngles) Quaternion ¶
func (ea *EulerAngles) Quaternion() quat.Number
Quaternion returns orientation in quaternion representation.
func (*EulerAngles) RotationMatrix ¶
func (ea *EulerAngles) RotationMatrix() *RotationMatrix
RotationMatrix returns the orientation in rotation matrix representation.
type Geometry ¶
type Geometry interface { Pose() Pose AlmostEqual(Geometry) bool Transform(Pose) Geometry ToProtobuf() *commonpb.Geometry CollidesWith(Geometry) (bool, error) DistanceFrom(Geometry) (float64, error) EncompassedBy(Geometry) (bool, error) Label() string // Label is the name of the geometry String() string // String is a string representation of the geometry data structure ToPoints(float64) []r3.Vector json.Marshaler }
Geometry is an entry point with which to access all types of collision geometries.
func NewGeometryFromProto ¶
NewGeometryFromProto instantiates a new Geometry from a protobuf Geometry message.
type GeometryConfig ¶
type GeometryConfig struct { Type GeometryType `json:"type"` // parameters used for defining a box's rectangular cross-section X float64 `json:"x"` Y float64 `json:"y"` Z float64 `json:"z"` // parameter used for defining a sphere's radius' R float64 `json:"r"` // define an offset to position the geometry TranslationOffset r3.Vector `json:"translation,omitempty"` OrientationOffset OrientationConfig `json:"orientation,omitempty"` Label string }
GeometryConfig specifies the format of geometries specified through the configuration file.
func NewGeometryConfig ¶
func NewGeometryConfig(gc Geometry) (*GeometryConfig, error)
NewGeometryConfig creates a config for a Geometry from an offset Pose.
func (*GeometryConfig) ParseConfig ¶
func (config *GeometryConfig) ParseConfig() (Geometry, error)
ParseConfig converts a GeometryConfig into the correct GeometryCreator type, as specified in its Type field.
func (*GeometryConfig) ToProtobuf ¶ added in v0.2.6
func (config *GeometryConfig) ToProtobuf() (*commonpb.Geometry, error)
ToProtobuf converts a GeometryConfig to Protobuf.
type GeometryType ¶ added in v0.1.0
type GeometryType string
GeometryType defines what geometry creator representations are known.
type Orientation ¶
type Orientation interface { OrientationVectorRadians() *OrientationVector OrientationVectorDegrees() *OrientationVectorDegrees AxisAngles() *R4AA Quaternion() quat.Number EulerAngles() *EulerAngles RotationMatrix() *RotationMatrix }
Orientation is an interface used to express the different parameterizations of the orientation of a rigid object or a frame of reference in 3D Euclidean space.
func NewZeroOrientation ¶
func NewZeroOrientation() Orientation
NewZeroOrientation returns an orientation which signifies no rotation.
func OrientationBetween ¶
func OrientationBetween(o1, o2 Orientation) Orientation
OrientationBetween returns the orientation representing the difference between the two given orientations.
func OrientationInverse ¶
func OrientationInverse(o Orientation) Orientation
OrientationInverse returns the orientation representing the inverse of the given orientation.
type OrientationConfig ¶
type OrientationConfig struct { Type OrientationType `json:"type"` Value json.RawMessage `json:"value,omitempty"` }
OrientationConfig holds the underlying type of orientation, and the value.
func NewOrientationConfig ¶
func NewOrientationConfig(o Orientation) (*OrientationConfig, error)
NewOrientationConfig encodes the orientation interface to something serializable and human readable.
func (*OrientationConfig) ParseConfig ¶
func (config *OrientationConfig) ParseConfig() (Orientation, error)
ParseConfig will use the Type in OrientationConfig and convert into the correct struct that implements Orientation.
type OrientationType ¶
type OrientationType string
OrientationType defines what orientation representations are known.
type OrientationVector ¶
type OrientationVector struct { Theta float64 `json:"th"` OX float64 `json:"x"` OY float64 `json:"y"` OZ float64 `json:"z"` }
OrientationVector containing ox, oy, oz, theta represents an orientation vector Structured similarly to an angle axis, an orientation vector works differently. Rather than representing an orientation with an arbitrary axis and a rotation around it from an origin, an orientation vector represents orientation such that the ox/oy/oz components represent the point on the cartesian unit sphere at which your end effector is pointing from the origin, and that unit vector forms an axis around which theta rotates. This means that incrementing/decrementing theta will perform an in-line rotation of the end effector. Theta is defined as rotation between two planes: the plane defined by the origin, the point (0,0,1), and the rx,ry,rz point, and the plane defined by the origin, the rx,ry,rz point, and the new local Z axis. So if theta is kept at zero as the north/south pole is circled, the Roll will correct itself to remain in-line.
func NewOrientationVector ¶
func NewOrientationVector() *OrientationVector
NewOrientationVector Creates a zero-initialized OrientationVector.
func QuatToOV ¶
func QuatToOV(q quat.Number) *OrientationVector
QuatToOV converts a quaternion to an orientation vector.
func (*OrientationVector) AxisAngles ¶
func (ov *OrientationVector) AxisAngles() *R4AA
AxisAngles returns the orientation in axis angle representation.
func (*OrientationVector) Degrees ¶
func (ov *OrientationVector) Degrees() *OrientationVectorDegrees
Degrees converts the OrientationVector to an OrientationVectorDegrees.
func (*OrientationVector) EulerAngles ¶
func (ov *OrientationVector) EulerAngles() *EulerAngles
EulerAngles returns orientation in Euler angle representation.
func (*OrientationVector) IsValid ¶
func (ov *OrientationVector) IsValid() error
IsValid returns an error if configuration is invalid.
func (*OrientationVector) Normalize ¶
func (ov *OrientationVector) Normalize()
Normalize scales the x, y, and z components of an Orientation Vector to be on the unit sphere.
func (*OrientationVector) OrientationVectorDegrees ¶
func (ov *OrientationVector) OrientationVectorDegrees() *OrientationVectorDegrees
OrientationVectorDegrees returns orientation as an orientation vector (in degrees).
func (*OrientationVector) OrientationVectorRadians ¶
func (ov *OrientationVector) OrientationVectorRadians() *OrientationVector
OrientationVectorRadians returns orientation as an orientation vector (in radians).
func (*OrientationVector) Quaternion ¶
func (ov *OrientationVector) Quaternion() quat.Number
Quaternion returns orientation in quaternion representation.
func (*OrientationVector) RotationMatrix ¶
func (ov *OrientationVector) RotationMatrix() *RotationMatrix
RotationMatrix returns the orientation in rotation matrix representation.
func (*OrientationVector) ToQuat ¶
func (ov *OrientationVector) ToQuat() quat.Number
ToQuat converts an orientation vector to a quaternion.
type OrientationVectorDegrees ¶
type OrientationVectorDegrees struct { Theta float64 `json:"th"` OX float64 `json:"x"` OY float64 `json:"y"` OZ float64 `json:"z"` }
OrientationVectorDegrees is the orientation vector between two objects, but expressed in degrees rather than radians. Because protobuf Pose is in degrees, this is necessary.
func NewOrientationVectorDegrees ¶
func NewOrientationVectorDegrees() *OrientationVectorDegrees
NewOrientationVectorDegrees Creates a zero-initialized OrientationVectorDegrees.
func QuatToOVD ¶
func QuatToOVD(q quat.Number) *OrientationVectorDegrees
QuatToOVD converts a quaternion to an orientation vector in degrees.
func (*OrientationVectorDegrees) AxisAngles ¶
func (ovd *OrientationVectorDegrees) AxisAngles() *R4AA
AxisAngles returns the orientation in axis angle representation.
func (*OrientationVectorDegrees) EulerAngles ¶
func (ovd *OrientationVectorDegrees) EulerAngles() *EulerAngles
EulerAngles returns orientation in Euler angle representation.
func (*OrientationVectorDegrees) IsValid ¶
func (ovd *OrientationVectorDegrees) IsValid() error
IsValid returns an error if configuration is invalid.
func (*OrientationVectorDegrees) Normalize ¶
func (ovd *OrientationVectorDegrees) Normalize()
Normalize scales the x, y, and z components of an Orientation Vector to be on the unit sphere.
func (*OrientationVectorDegrees) OrientationVectorDegrees ¶
func (ovd *OrientationVectorDegrees) OrientationVectorDegrees() *OrientationVectorDegrees
OrientationVectorDegrees returns orientation as an orientation vector (in degrees).
func (*OrientationVectorDegrees) OrientationVectorRadians ¶
func (ovd *OrientationVectorDegrees) OrientationVectorRadians() *OrientationVector
OrientationVectorRadians returns orientation as an orientation vector (in radians).
func (*OrientationVectorDegrees) Quaternion ¶
func (ovd *OrientationVectorDegrees) Quaternion() quat.Number
Quaternion returns orientation in quaternion representation.
func (*OrientationVectorDegrees) Radians ¶
func (ovd *OrientationVectorDegrees) Radians() *OrientationVector
Radians converts a OrientationVectorDegrees to an OrientationVector.
func (*OrientationVectorDegrees) RotationMatrix ¶
func (ovd *OrientationVectorDegrees) RotationMatrix() *RotationMatrix
RotationMatrix returns the orientation in rotation matrix representation.
func (*OrientationVectorDegrees) ToQuat ¶
func (ovd *OrientationVectorDegrees) ToQuat() quat.Number
ToQuat converts an orientation vector in degrees to a quaternion.
type Pose ¶
type Pose interface { Point() r3.Vector Orientation() Orientation }
Pose represents a 6dof pose, position and orientation, with respect to the origin. The Point() method returns the position in (x,y,z) mm coordinates, and the Orientation() method returns an Orientation object, which has methods to parametrize the rotation in multiple different representations.
func Compose ¶
Compose treats Poses as functions A(x) and B(x), and produces a new function C(x) = A(B(x)). It converts the poses to dual quaternions and multiplies them together, normalizes the transform and returns a new Pose. Composition does not commute in general, i.e. you cannot guarantee ABx == BAx.
func Interpolate ¶
Interpolate will return a new Pose that has been interpolated the set amount between two poses. Note that position and orientation are interpolated separately, then the two are combined. Note that slerp(q1, q2) != slerp(q2, q1) p1 and p2 are the two poses to interpolate between, by is a float representing the amount to interpolate between them. by == 0 will return p1, by == 1 will return p2, and by == 0.5 will return the pose halfway between them.
func NewPose ¶ added in v0.2.11
func NewPose(p r3.Vector, o Orientation) Pose
NewPose takes in a position and orientation and returns a Pose.
func NewPoseFromDH ¶
NewPoseFromDH creates a new pose from denavit hartenberg parameters.
func NewPoseFromOrientation ¶
func NewPoseFromOrientation(o Orientation) Pose
NewPoseFromOrientation takes in an orientation and returns a Pose. It will have the same position as the frame it is in reference to.
func NewPoseFromPoint ¶
NewPoseFromPoint takes in a cartesian (x,y,z) and stores it as a vector. It will have the same orientation as the frame it is in reference to.
func NewPoseFromProtobuf ¶
NewPoseFromProtobuf creates a new pose from a protobuf pose.
func NewZeroPose ¶
func NewZeroPose() Pose
NewZeroPose returns a pose at (0,0,0) with same orientation as whatever frame it is placed in.
func PoseBetween ¶
PoseBetween returns the difference between two dualQuaternions, that is, the dq which if multiplied by one will give the other.
func PoseDelta ¶
PoseDelta returns the difference between two dualQuaternion. We use quaternion/angle axis for this because distances are well-defined.
func PoseInverse ¶
PoseInverse will return the inverse of a pose. So if a given pose p is the pose of A relative to B, PoseInverse(p) will give the pose of B relative to A.
type Quaternion ¶
Quaternion is an orientation in quaternion representation.
func (*Quaternion) AxisAngles ¶
func (q *Quaternion) AxisAngles() *R4AA
AxisAngles returns the orientation in axis angle representation.
func (*Quaternion) EulerAngles ¶
func (q *Quaternion) EulerAngles() *EulerAngles
EulerAngles returns orientation in Euler angle representation.
func (*Quaternion) MarshalJSON ¶
func (q *Quaternion) MarshalJSON() ([]byte, error)
MarshalJSON marshals to W, X, Y, Z json.
func (*Quaternion) OrientationVectorDegrees ¶
func (q *Quaternion) OrientationVectorDegrees() *OrientationVectorDegrees
OrientationVectorDegrees returns orientation as an orientation vector (in degrees).
func (*Quaternion) OrientationVectorRadians ¶
func (q *Quaternion) OrientationVectorRadians() *OrientationVector
OrientationVectorRadians returns orientation as an orientation vector (in radians).
func (*Quaternion) Quaternion ¶
func (q *Quaternion) Quaternion() quat.Number
Quaternion returns orientation in quaternion representation.
func (*Quaternion) RotationMatrix ¶
func (q *Quaternion) RotationMatrix() *RotationMatrix
RotationMatrix returns the orientation in rotation matrix representation.
type R4AA ¶
type R4AA struct { Theta float64 `json:"th"` RX float64 `json:"x"` RY float64 `json:"y"` RZ float64 `json:"z"` }
R4AA represents an R4 axis angle.
func QuatToR4AA ¶
QuatToR4AA converts a quat to an R4 axis angle in the same way the C++ Eigen library does. https://eigen.tuxfamily.org/dox/AngleAxis_8h_source.html
func (*R4AA) AxisAngles ¶
AxisAngles returns the orientation in axis angle representation.
func (*R4AA) EulerAngles ¶
func (r4 *R4AA) EulerAngles() *EulerAngles
EulerAngles returns orientation in Euler angle representation.
func (*R4AA) Normalize ¶
func (r4 *R4AA) Normalize()
Normalize scales the x, y, and z components of a R4 axis angle to be on the unit sphere.
func (*R4AA) OrientationVectorDegrees ¶
func (r4 *R4AA) OrientationVectorDegrees() *OrientationVectorDegrees
OrientationVectorDegrees returns orientation as an orientation vector (in degrees).
func (*R4AA) OrientationVectorRadians ¶
func (r4 *R4AA) OrientationVectorRadians() *OrientationVector
OrientationVectorRadians returns orientation as an orientation vector (in radians).
func (*R4AA) Quaternion ¶
Quaternion returns orientation in quaternion representation.
func (*R4AA) RotationMatrix ¶
func (r4 *R4AA) RotationMatrix() *RotationMatrix
RotationMatrix returns the orientation in rotation matrix representation.
func (*R4AA) ToQuat ¶
ToQuat converts an R4 axis angle to a unit quaternion See: https://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm1
type RotationMatrix ¶
type RotationMatrix struct {
// contains filtered or unexported fields
}
RotationMatrix is a 3x3 matrix in row major order. m[3*r + c] is the element in the r'th row and c'th column.
func MatMul ¶ added in v0.1.2
func MatMul(a, b RotationMatrix) *RotationMatrix
MatMul returns the product of one matrix A applied to B as AB = C
func NewRotationMatrix ¶
func NewRotationMatrix(m []float64) (*RotationMatrix, error)
NewRotationMatrix creates the rotation matrix from a slice of floats.
func QuatToRotationMatrix ¶
func QuatToRotationMatrix(q quat.Number) *RotationMatrix
QuatToRotationMatrix converts a quat to a Rotation Matrix reference: https://github.com/go-gl/mathgl/blob/592312d8590acb0686c14740dcf60e2f32d9c618/mgl64/quat.go#L168
func (*RotationMatrix) At ¶
func (rm *RotationMatrix) At(row, col int) float64
At returns the float corresponding to the element at the specified location.
func (*RotationMatrix) AxisAngles ¶
func (rm *RotationMatrix) AxisAngles() *R4AA
AxisAngles returns the orientation in axis angle representation.
func (*RotationMatrix) Col ¶
func (rm *RotationMatrix) Col(col int) r3.Vector
Col returns the a 3 element vector corresponding to the specified col.
func (*RotationMatrix) EulerAngles ¶
func (rm *RotationMatrix) EulerAngles() *EulerAngles
EulerAngles returns orientation in Euler angle representation.
func (*RotationMatrix) LeftMatMul ¶ added in v0.1.2
func (rm *RotationMatrix) LeftMatMul(lmm RotationMatrix) *RotationMatrix
LeftMatMul returns the right side multiplication a matrix A by matrix B, AB.
func (*RotationMatrix) Mul ¶
func (rm *RotationMatrix) Mul(v r3.Vector) r3.Vector
Mul returns the product of the rotation Matrix with an r3 Vector.
func (*RotationMatrix) OrientationVectorDegrees ¶
func (rm *RotationMatrix) OrientationVectorDegrees() *OrientationVectorDegrees
OrientationVectorDegrees returns orientation as an orientation vector (in degrees).
func (*RotationMatrix) OrientationVectorRadians ¶
func (rm *RotationMatrix) OrientationVectorRadians() *OrientationVector
OrientationVectorRadians returns orientation as an orientation vector (in radians).
func (*RotationMatrix) Quaternion ¶
func (rm *RotationMatrix) Quaternion() quat.Number
Quaternion returns orientation in quaternion representation. reference: http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
func (*RotationMatrix) RightMatMul ¶ added in v0.1.2
func (rm *RotationMatrix) RightMatMul(rmm RotationMatrix) *RotationMatrix
RightMatMul returns the left side multiplication a matrix A by matrix B, BA
func (*RotationMatrix) RotationMatrix ¶
func (rm *RotationMatrix) RotationMatrix() *RotationMatrix
RotationMatrix returns the orientation in rotation matrix representation.