public final class ARPose
- Object
- ARPose
An immutable rigid transform - a rotation followed by a translation - that positions something in AR world space. Poses use the AR coordinate convention shared by ARKit and ARCore: units are meters, the coordinate system is right-handed with Y pointing up and -Z pointing forward from the initial camera direction.
The rotation is stored as a unit quaternion (qx, qy, qz, qw) compatible
with com.codename1.gpu.Quaternion; the translation is (tx, ty, tz).
toMatrix(float[]) produces the equivalent column-major 4x4 matrix, ready
for com.codename1.gpu.Matrix4 math.
Fields
public static final ARPose IDENTITY | The identity pose: no rotation, located at the world origin. |
Constructors
public ARPose(float tx, float ty, float tz, float qx, float qy, float qz, float qw) | Creates a pose from a translation and a rotation quaternion. |
Methods
public static ARPose fromMatrix(float[] m16) | Extracts a pose from a column-major 4x4 transform matrix whose upper left 3x3 is a pure rotation (no scale or shear). |
public float getTx() | The X component of the translation in meters. |
public float getTy() | The Y component of the translation in meters. |
public float getTz() | The Z component of the translation in meters. |
public float getQx() | The X component of the rotation quaternion. |
public float getQy() | The Y component of the rotation quaternion. |
public float getQz() | The Z component of the rotation quaternion. |
public float getQw() | The W component of the rotation quaternion. |
public void toMatrix(float[] out16) | Writes this pose as a column-major 4x4 transform matrix into out16, compatible with com.codename1.gpu.Matrix4. |
public float[] toMatrix() | Returns this pose as a newly allocated column-major 4x4 transform matrix. |
public ARPose transform(ARPose local) | Composes this pose with a pose expressed in this pose’s local frame, returning this * local. |
public void transformPoint(float[] xyzInOut) | Transforms the point stored in xyzInOut (3 floats) from this pose’s local frame to the frame this pose is expressed in, writing the result back in place. |
public String toString() | Returns a string representation of the object. |
Inherited methods
Field details
IDENTITY
public static final ARPose IDENTITYThe identity pose: no rotation, located at the world origin.
Constructor details
ARPose
public ARPose(float tx, float ty, float tz, float qx, float qy, float qz, float qw)Creates a pose from a translation and a rotation quaternion. The
quaternion is normalized defensively; a zero quaternion becomes the
identity rotation.
Parameters
txfloat- ,
ty,tz: the translation in meters tyfloat- Not documented.
tzfloat- Not documented.
qxfloat- ,
qy,qz,qw: the rotation quaternion qyfloat- Not documented.
qzfloat- Not documented.
qwfloat- Not documented.
Method details
fromMatrix
public static ARPose fromMatrix(float[] m16)Extracts a pose from a column-major 4x4 transform matrix whose upper
left 3x3 is a pure rotation (no scale or shear).
Parameters
m16float[]- the column-major matrix, 16 floats
Returns
the equivalent pose
getTx
public float getTx()The X component of the translation in meters.
getTy
public float getTy()The Y component of the translation in meters.
getTz
public float getTz()The Z component of the translation in meters.
getQx
public float getQx()The X component of the rotation quaternion.
getQy
public float getQy()The Y component of the rotation quaternion.
getQz
public float getQz()The Z component of the rotation quaternion.
getQw
public float getQw()The W component of the rotation quaternion.
toMatrix
public void toMatrix(float[] out16)Writes this pose as a column-major 4x4 transform matrix into
out16,
compatible with com.codename1.gpu.Matrix4.Parameters
out16float[]- the destination array, 16 floats
toMatrix
public float[] toMatrix()Returns this pose as a newly allocated column-major 4x4 transform
matrix.
transform
public ARPose transform(ARPose local)Composes this pose with a pose expressed in this pose’s local frame,
returning
this * local. Use it to convert an offset relative to an
anchor into world space.Parameters
localARPose- the pose in this pose’s local coordinate frame
Returns
the composed pose in the frame this pose is expressed in
transformPoint
public void transformPoint(float[] xyzInOut)Transforms the point stored in
xyzInOut (3 floats) from this pose’s
local frame to the frame this pose is expressed in, writing the result
back in place.Parameters
xyzInOutfloat[]- the point to transform, modified in place
toString
public String toString()Returns a string representation of the object. In general, the toString method returns a string that “textually represents” this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.
The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@’, and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + ‘@’ + Integer.toHexString(hashCode())