Class 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.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionARPose(float tx, float ty, float tz, float qx, float qy, float qz, float qw) Creates a pose from a translation and a rotation quaternion. -
Method Summary
Modifier and TypeMethodDescriptionstatic ARPosefromMatrix(float[] m16) Extracts a pose from a column-major 4x4 transform matrix whose upper left 3x3 is a pure rotation (no scale or shear).floatgetQw()The W component of the rotation quaternion.floatgetQx()The X component of the rotation quaternion.floatgetQy()The Y component of the rotation quaternion.floatgetQz()The Z component of the rotation quaternion.floatgetTx()The X component of the translation in meters.floatgetTy()The Y component of the translation in meters.floatgetTz()The Z component of the translation in meters.float[]toMatrix()Returns this pose as a newly allocated column-major 4x4 transform matrix.voidtoMatrix(float[] out16) Writes this pose as a column-major 4x4 transform matrix intoout16, compatible withcom.codename1.gpu.Matrix4.toString()Returns a string representation of the object.Composes this pose with a pose expressed in this pose's local frame, returningthis * local.voidtransformPoint(float[] xyzInOut) Transforms the point stored inxyzInOut(3 floats) from this pose's local frame to the frame this pose is expressed in, writing the result back in place.
-
Field Details
-
IDENTITY
The 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
-
tx,ty,tz: the translation in meters -
qx,qy,qz,qw: the rotation quaternion
-
-
-
Method Details
-
fromMatrix
Extracts a pose from a column-major 4x4 transform matrix whose upper left 3x3 is a pure rotation (no scale or shear).
Parameters
m16: 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 withcom.codename1.gpu.Matrix4.Parameters
out16: the destination array, 16 floats
-
toMatrix
public float[] toMatrix()Returns this pose as a newly allocated column-major 4x4 transform matrix. -
transform
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
local: 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
xyzInOut: the point to transform, modified in place
-
toString
Description copied from class:ObjectReturns 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())
-