目录

ARPose

Class Info

public class ARPose

位姿数据类,包含平移向量和旋转向量(四元组)。

  1. 在AR Engine中,其用于描述物体从局部坐标系向世界坐标系的转换,局部坐标通过该类的对象转化成世界坐标系下的坐标。
  2. AR Engine中的世界坐标系是右手坐标系(与OpenGL一致),上 -> y轴正方向,x和z轴在水平面上。该类的对象等价于OpenGL中的变换矩阵。

Public Field Summary

Qualifier and Type

Field and Description

public static final ARPose

IDENTITY

单位位姿(从局部坐标系到世界坐标系的转移),初始值:

平移变量:X:0,Y:0,Z:0

旋转变量:X:0,Y:0,Z:0,W:1。

另请参阅:Constant-values

Public Constructor Summary

Constructor Name

ARPose(float[] translation, float[] rotation)

通过特定的平移向量和旋转向量构造位姿类,其中translation是从目的坐标系到局部坐标系的位移向量,rotation是Hamilton四元组。

Public Method Summary

Qualifier and Type

Method Name and Description

ARPose

compose(ARPose rhs)

返回this与rhs的复合。一个点通过该方法返回的pose的变换等价于先通过rhs变换,然后通过this变换。返回结果满足如下关系,result.toMatrix() = this.toMatrix() * rhs.toMatrix()。

ARPose

extractRotation()

返回仅包含this旋转向量的pose。

ARPose

extractTranslation()

返回仅包含this平移向量的位姿信息。

void

getRotationQuaternion(float[] dest, int offset)

获取旋转四元组,放入dest中,初始偏移为offset。dest为存放结果的数组,其中的数据存放顺序为x、y、z、w。

void

getTranslation(float[] dest, int offset)

获取平移向量,放入dest中,初始偏移为offset。

float[]

getTransformedAxis(int axis, float scale)

返回局部坐标系的某个坐标轴单位坐标向量,axis的取值0=X, 1=Y, 2=Z;scale为轴向量长度。

void

getTransformedAxis(int axis, float scale, float[] dest, int offset)

获取局部坐标系的某个坐标轴单位坐标向量,axis的取值0=X,1=Y,2=Z;scale为轴向量的长度;结果存入dest数组中,初始偏移为offset。

float[]

getXAxis()

返回ARPose在X轴的单位坐标向量,返回的数组长度是3。

float[]

getYAxis()

返回ARPose在Y轴的单位坐标向量,返回的数组长度是3。

float[]

getZAxis()

返回ARPose在Z轴的单位坐标向量,返回的数组长度是3。

ARPose

inverse()

返回执行相反转换的pose(世界坐标系->局部坐标系)。

ARPose

makeInterpolated(ARPose pose1, ARPose pose2, float proportion)

返回pose1与pose2的插值pose,在平移向量上执行线性插值,在旋转向量上执行球面线性插值。result = (1- proportion)*pose1+ proportion* pose2。proportion为插值的取值范围为[0,1]。

ARPose

makeRotation(float x, float y, float z, float w)

根据提供的旋转向量构造pose,平移向量为0。

ARPose

makeRotation(float[] quaternion)

根据提供的旋转向量构造pose,平移向量为0。

ARPose

makeTranslation(float tx, float ty, float tz)

根据提供的平移向量构造pose,旋转向量为0。

ARPose

makeTranslation(float[] translation)

根据提供的平移向量构造pose,旋转向量为0。

float

qw()

获取构造ARPose时使用的旋转变量中的w分量。

float

qx()

获取构造ARPose时使用的旋转变量中的x分量。

float

qy()

获取构造ARPose时使用的旋转变量中的y分量。

float

qz()

获取构造ARPose时使用的旋转变量中的z分量。

void

rotateVector(float[] vectorIn, int inOffset, float[] vectorOut, int outOffset)

根据this的旋转向量,对坐标点只进行旋转操作,不执行平移。vectorIn是输入的向量,inOffset是其初始偏移;vectorOut是输出向量,outOffset是其初始偏移。

void

toMatrix(float[] dest, int offset)

将位姿数据转换成4X4的矩阵,dest为存放数组,其中的数据按照列优先存储,使用指定对象的toMatrix()获取的矩阵与局部坐标系的坐标点做乘法,可以得到局部坐标系到世界坐标系的转换。

float[]

transformPoint(float[] x)

将局部坐标系的点坐标转化成世界坐标系的点坐标。x的坐标有3个分量。等价于result=this.toMatrix()*x,返回数组的长度为3,result表示x在世界坐标系的表示。

void

transformPoint(float[] pointIn, int inOffset, float[] pointOut, int outOffset)

将局部坐标系的点坐标转化成世界坐标系的点坐标。输入点的坐标为pointIn[inOffset..inOffset+2],分别表示X、Y、Z的坐标,结果放入pointOut[outOffset..outOffset+2]。

float

tx()

获取构造ARPose时使用的平移向量x分量。

float

ty()

获取构造ARPose时使用的平移向量y分量。

float

tz()

获取构造ARPose时使用的平移向量z分量。

Public Fields

[h2]IDENTITY

Field

public static final ARPose IDENTITY

单位位姿(从局部坐标系到世界坐标系的转移),初始值:

平移变量:X:0,Y:0,Z:0

旋转变量:X:0,Y:0,Z:0,W:1。

另请参阅:Constant-values

Public Constructors

[h2]ARPose

Constructor

public ARPose(float[] translation, float[] rotation)

通过特定的平移向量和旋转向量构造位姿类,其中translation是从目的坐标系到局部坐标系的位移向量,rotation是Hamilton四元组。

Parameters

Name

Description

translation

从目的坐标系到局部坐标系的位移向量。

rotation

旋转变量,是Hamilton四元组。

Public Methods

[h2]compose

Method

public ARPose compose(ARPose rhs)

返回this与rhs的复合。一个点通过该方法返回的pose的变换等价于先通过rhs变换,然后通过this变换。返回结果满足如下关系,result.toMatrix() = this.toMatrix() * rhs.toMatrix()。

Parameters

Name

Description

rhs

待转换的位姿信息。

Returns

Type

Description

ARPose

this与rhs的复合结果,满足result.toMatrix() = this.toMatrix() * rhs.toMatrix()。

[h2]extractRotation

Method

public ARPose extractRotation()

返回仅包含this旋转向量的pose。

Returns

Type

Description

ARPose

仅包含this旋转向量的位姿信息。

[h2]extractTranslation

Method

public ARPose extractTranslation()

返回仅包含this平移向量的位姿信息。

Returns

Type

Description

ARPose

仅包含this平移向量的位姿信息。

[h2]getRotationQuaternion

Method

public void getRotationQuaternion(float[] dest, int offset)

获取旋转四元组,放入dest中,初始偏移为offset。dest为存放结果的数组,其中的数据存放顺序为x、y、z、w。

Parameters

Name

Description

dest

获取得到的旋转四元组信息。

offset

存放在dest中的初始偏移量。

[h2]getTranslation

Method

public void getTranslation (float[] dest, int offset)

获取平移向量,放入dest中,初始偏移为offset。

Parameters

Name

Description

dest

获取得到的平移变量。

offset

存放在dest中的初始偏移量。

[h2]getTransformedAxis(int axis, float scale)

Method

public float[] getTransformedAxis(int axis, float scale)

返回局部坐标系的某个坐标轴单位坐标向量,axis的取值0=X, 1=Y, 2=Z;scale为轴向量长度。

Parameters

Name

Description

axis

需要获取的坐标轴参数,取值0=X, 1=Y, 2=Z。

scale

轴向量长度。

Returns

Type

Description

float[]

局部坐标系的某个坐标轴单位坐标向量。

[h2]getTransformedAxis

Method

public void getTransformedAxis(int axis, float scale, float[] dest, int offset)

获取局部坐标系的某个坐标轴单位坐标向量,axis的取值0代表X轴,1代表Y轴,2代表Z轴;scale为轴向量的长度;结果存入dest数组中,初始偏移为offset。

Parameters

Name

Description

axis

需要获取的坐标轴参数,取值0代表X轴,1代表Y轴,2代表Z轴。

scale

轴向量长度。

dest

获取得到的坐标轴单位坐标向量。

offset

存放在dest中的初始偏移量。

[h2]getXAxis

Method

public float[] getXAxis()

返回ARPose在X轴的单位坐标向量,返回的数组长度是3。

Returns

Type

Description

float[]

ARPose在X轴的单位坐标向量,长度是3。

[h2]getYAxis

Method

public float[] getYAxis()

返回ARPose在Y轴的单位坐标向量,返回的数组长度是3。

Returns

Type

Description

float[]

ARPose在Y轴的单位坐标向量,长度是3。

[h2]getZAxis

Method

public float[] getZAxis()

返回ARPose在Z轴的单位坐标向量,返回的数组长度是3。

Returns

Type

Description

float[]

ARPose在Z轴的单位坐标向量,长度是3。

[h2]inverse

Method

public ARPose inverse()

返回执行相反转换的pose(世界坐标系->局部坐标系)。

Returns

Type

Description

ARPose

转换后的位姿信息。

[h2]makeInterpolated

Method

public static ARPose makeInterpolated(ARPose pose1, ARPose pose2, float proportion)

返回pose1与pose2的插值pose,在平移向量上执行线性插值,在旋转向量上执行球面线性插值。result = (1-proportion)*pose1+proportion*pose2。proportion为插值的取值范围为[0,1]。

Parameters

Name

Description

pose1

用于计算插值的Pose变量。

pose2

用于计算插值的Pose变量。

proportion

用于计算插值的比例信息。

Returns

Type

Description

ARPose

pose1与pose2的插值pose。

[h2]makeRotation(float[] quaternion)

Method

public static ARPose makeRotation(float[] quaternion)

根据提供的旋转向量构造pose。平移向量为0。

Parameters

Name

Description

quaternion

旋转变量信息,格式为[x,y,z,w]。

Returns

Type

Description

ARPose

根据提供的旋转向量构造pose。

[h2]makeRotation

Method

public static ARPose makeRotation(float x, float y, float z, float w)

根据提供的旋转向量构造pose。平移向量为0。

Parameters

Name

Description

x

x轴坐标。

y

y轴坐标。

z

z轴坐标。

w

w坐标。

Returns

Type

Description

ARPose

根据提供的旋转向量构造pose。

[h2]makeTranslation(float[] translation)

Method

public static ARPose makeTranslation(float[] translation)

根据提供的平移向量构造pose,旋转向量为0。

Parameters

Name

Description

translation

平移向量信息,格式为[x,y,z]。

Returns

Type

Description

ARPose

根据提供的平移向量构造pose。

[h2]makeTranslation

Method

public static ARPose makeTranslation(float tx, float ty, float tz)

根据提供的平移向量构造pose,旋转向量为0。

Parameters

Name

Description

x

x轴坐标。

y

y轴坐标。

z

z轴坐标。

Returns

Type

Description

ARPose

根据提供的平移向量构造pose。

[h2]qw

Method

public float qw()

获取构造ARPose时使用的w分量。

Returns

Type

Description

float

构造ARPose时使用的w分量。

[h2]qx

Method

public float qx()

获取构造ARPose时使用的x分量。

Returns

Type

Description

float

构造ARPose时使用的x分量。

[h2]qy

Method

public float qy()

获取构造ARPose时使用的y分量。

Returns

Type

Description

float

构造ARPose时使用的y分量。

[h2]qz

Method

public float qz()

获取构造ARPose时使用的z分量。

Returns

Type

Description

float

构造ARPose时使用的z分量。

[h2]rotateVector

Method

public void rotateVector (float[] vectorIn, int inOffset, float[] vectorOut, int outOffset)

根据this的旋转向量,旋转局部坐标系的向量,不执行平移。vectorIn是输入的向量,inOffset是其初始偏移;vectorOut是输出向量,outOffset是其初始偏移。

Parameters

Name

Description

vectorIn

需要执行旋转的输入向量。

inOffset

输入向量初始化偏移。

vectorOut

执行旋转后的输出向量。

outOffset

输出向量初始化偏移。

[h2]toMatrix

Method

public void toMatrix(float[] dest, int offset)

将位姿数据转换成4X4的矩阵,dest为存放数组,其中的数据按照列优先存储,使用指定对象的toMatrix()获取的矩阵与局部坐标系的坐标点做乘法,可以得到局部坐标系到世界坐标系的转换。

Parameters

Name

Description

dest

转换后的矩阵信息。

offset

存放在dest中的初始偏移量。

[h2]transformPoint(float[] x)

Method

public float[] transformPoint(float[] x)

将局部坐标系的点坐标转化成世界坐标系的点坐标。x的坐标有3个分量。等价于result=this.toMatrix()*x,返回数组的长度为3,result表示x在世界坐标系的表示。

Parameters

Name

Description

x

局部坐标系的坐标信息。

Returns

Type

Description

float[]

转换得到的世界坐标系坐标信息,长度为3。

[h2]transformPoint

Method

public void transformPoint (float[] pointIn, int inOffset, float[] pointOut, int outOffset)

将局部坐标系的点坐标转化成世界坐标系的点坐标。输入点的坐标为pointIn[inOffset..inOffset+2],分别表示X、Y、Z的坐标,结果放入pointOut[outOffset..outOffset+2]。

Parameters

Name

Description

pointIn

输入的局部坐标系信息。

inOffset

输入点初始偏移量。

pointOut

输出的世界坐标系信息。

outOffset

输出点初始偏移量。

[h2]tx

Method

public float tx()

获取构造ARPose时使用的平移向量x分量。

Returns

Type

Description

float

构造ARPose时使用的平移向量x分量。

[h2]ty

Method

public float ty()

获取构造ARPose时使用的平移向量y分量。

Returns

Type

Description

float

构造ARPose时使用的平移向量y分量。

[h2]tz

Method

public float tz()

获取构造ARPose时使用的平移向量z分量。

Returns

Type

Description

float

构造ARPose时使用的平移向量z分量。