Algorithm implementation of pose class transform points in Arcore

Source: Internet
Author: User

The algorithm realization of pose class transform point in Arcore is divided into two steps, namely translation and rotation.

1. Rotation vector: Calculates the rotated vector by four-dollar number

List of parameters: Q for four Yuan,

V is a float array of length 4 that represents the vector to be rotated,

Offsetin represents the starting index of the first coordinate value,

Out represents the result vector,

The offsetout represents the starting index of the three coordinate values of the result vector in the out array.

1      Public Static voidRotatevector (quaternion Q,float[] V,intOffsetin,float[] out,intoffsetout) {2         floatx = v[offsetin + 0];3         floaty = v[offsetin + 1];4         floatz = v[offsetin + 2];5         floatQX =q.x ();6         floatQY =q.y ();7         floatQZ =q.z ();8         floatQW =Q.W ();9         floatIX = QW * x + qy * Z-QZ *y;Ten         floatiy = qw * y + QZ * x-qx *Z; One         floatiz = QW * z + qx * y-qy *x; A         floatIW =-qx * x-qy * Y-QZ *Z; -Out[offsetout + 0] = IX * QW + IW *-qx + iy *-qz-iz *-qy; -Out[offsetout + 1] = iy * QW + IW *-qy + iz *-qx-ix *-QZ; theOut[offsetout + 2] = iz * QW + IW *-QZ + IX *-qy-iy *-QX; -}

2. Transform a point:

Parameter list: Pointin represents an array containing the points to be transformed.

Inoffset represents the starting index of the point to be transformed in the array,

Pointout represents an array of point coordinates written to the transformation,

The outoffset represents the starting index of the changed point coordinate in the pointout array.

1      Public voidTransformpoint (float[] Pointin,intInoffset,float[] Pointout,intOutoffset) {2 Rotatevector (Pointin, Inoffset, Pointout, outoffset);//rotate point first: equivalent to R * Pointin3 4          for(inti = 0; I < 3; ++i) {5Pointout[i + Outoffset] + = This. translation[i];//translation point: equivalent to T * pointin6         }7}

This method is equivalent to: pointout = m * Pointin, where m = T * R

Algorithm implementation of pose class transform points in Arcore

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.