Pose
class Pose
Represents an immutable rigid transformation from one coordinate space to another.
Summary
Public companion functions |
|
|---|---|
Float |
Returns the distance between the two poses. |
Pose |
fromLookAt(eye: Vector3, target: Vector3, up: Vector3)Returns a new pose oriented to look at |
Pose |
Returns a new pose that is linearly interpolated between |
Public constructors |
|---|
|
Creates a new pose with the same values as the |
Pose(translation: Vector3, rotation: Quaternion) |
Public functions |
|
|---|---|
infix Pose |
Returns the result of composing |
Pose |
copy(translation: Vector3, rotation: Quaternion)Returns a copy of the pose. |
open operator Boolean |
Returns true if this pose is equal to the |
Quaternion |
getForwardVectorToUpRotation(other: Pose)Calculates a rotation to align this pose's local Z-axis |
Quaternion |
getUpVectorToUpRotation(other: Pose)Calculates a rotation to align this pose's local Y-axis |
open Int |
hashCode() |
Pose |
rotate(rotation: Quaternion)Rotates this pose by the given |
open String |
toString() |
infix Vector3 |
transformPoint(point: Vector3)Transforms the provided |
infix Vector3 |
transformVector(vector: Vector3)Transforms the provided |
Pose |
Translates this pose by the given |
Public properties |
|
|---|---|
Vector3 |
The backward vector in the local coordinate system. |
Vector3 |
The down vector in the local coordinate system. |
Vector3 |
The forward vector in the local coordinate system. |
Pose |
Returns a pose that performs the opposite transformation. |
Vector3 |
The left vector in the local coordinate system. |
Vector3 |
The right vector in the local coordinate system. |
Quaternion |
the rotation component of this pose |
Vector3 |
the translation component of this pose |
Vector3 |
The up vector in the local coordinate system. |
Public companion functions
distance
fun distance(lhs: Pose, rhs: Pose): Float
Returns the distance between the two poses.
fromLookAt
fun fromLookAt(eye: Vector3, target: Vector3, up: Vector3 = Vector3.Up): Pose
Returns a new pose oriented to look at target from eye position with up as the up vector.
lerp
fun lerp(start: Pose, end: Pose, ratio: Float): Pose
Returns a new pose that is linearly interpolated between start and end using the interpolation amount ratio. The position is lerped, but the rotation will be slerped if the angles are far apart.
If ratio is outside of the range [0, 1], the returned pose will be extrapolated.
Public companion properties
Public constructors
Pose
Pose(other: Pose)
Creates a new pose with the same values as the other pose.
Pose
Pose(translation: Vector3 = Vector3(), rotation: Quaternion = Quaternion())
Public functions
compose
infix fun compose(other: Pose): Pose
Returns the result of composing this with other.
copy
fun copy(
translation: Vector3 = this.translation,
rotation: Quaternion = this.rotation
): Pose
Returns a copy of the pose.
| Parameters | |
|---|---|
translation: Vector3 = this.translation |
the new translation for the copied pose |
rotation: Quaternion = this.rotation |
the new rotation for the copied pose |
equals
open operator fun equals(other: Any?): Boolean
Returns true if this pose is equal to the other.
getForwardVectorToUpRotation
fun getForwardVectorToUpRotation(other: Pose): Quaternion
Calculates a rotation to align this pose's local Z-axis forward with the given pose's up direction.
| Parameters | |
|---|---|
other: Pose |
The given pose. |
| Returns | |
|---|---|
Quaternion |
A Quaternion representing the rotation to apply to the pose. |
getUpVectorToUpRotation
fun getUpVectorToUpRotation(other: Pose): Quaternion
Calculates a rotation to align this pose's local Y-axis up with the given pose's up direction.
| Parameters | |
|---|---|
other: Pose |
The given pose. |
| Returns | |
|---|---|
Quaternion |
A Quaternion representing the rotation to apply to the pose. |
rotate
fun rotate(rotation: Quaternion): Pose
Rotates this pose by the given rotation.
transformPoint
infix fun transformPoint(point: Vector3): Vector3
Transforms the provided point by the pose by applying both the rotation and the translation components of the pose. This is because a point represents a specific location in space. It needs to account for the position, scale and orientation of the space it is in.
transformVector
infix fun transformVector(vector: Vector3): Vector3
Transforms the provided vector by the pose by only applying the rotation component of the pose. This is because a vector represents a direction and magnitude, not a specific location. It only needs to account for the scale and orientation of the space it is in since it has no position.
translate
fun translate(translation: Vector3): Pose
Translates this pose by the given translation.
Public properties
backward
val backward: Vector3
The backward vector in the local coordinate system.
forward
val forward: Vector3
The forward vector in the local coordinate system.
inverse
val inverse: Pose
Returns a pose that performs the opposite transformation.