开发者

constructing optimized matrix from calibration/reference matrix only? possible/solvable?

Imagine a gravity/rotation sensor of iPhone that for each attitude of the device provides a gravity vector (Vg) and a current 3x3 rotation matrix (M0). Such as:

Vg * M0 = Vz
Vz * Mt = Vg

where:
  Vg - c开发者_运维问答urrent gravity vector
  M0 - current rotation matrix
  Mt - inverse (or actually transpose) matrix of M0
  Vz - negative Z-axis vector = { 0, 0, -1 }

There is a need to have an option to calibrate the accelometer and gyroscope by all axis that means we would like to store the reference matrix (C0) for the reference gravity vector (Vc) at some moment of time. So:

Vc * C0 = Vz
Vz * Ct = Vc

where:
  Vc - reference gravity vector
  C0 - reference rotation matrix
  Ct - inverse (or actually transpose) matrix of C0
  Vz - negative Z-axis vector = { 0, 0, -1 }

Now if we will use the reference matrix as a zero-reference one then the calibrated gravity (Vx) or a gravity in relation to the reference one (Vc) is possible to be computed with the composite rotation matrix (X0). So:

Vg * X0 = Vc
Vc * Xt = Vg
-->
M0 = X0 * C0 --> X0 = X0 * C0 * Ct --> X0 = M0 * Ct
Mt = Ct * Xt --> Xt = C0 * Ct * Xt --> Xt = C0 * Mt
-->
Vx * X0 = Vz
Vz * Xt = Vx

where:
  Vx - computed (calibrated) gravity vector
  X0 - composite rotation matrix
  Xt - inverse (or actually transpose) matrix of X0
  Vg - current gravity vector
  M0 - current rotation matrix
  Mt - inverse (or actually transpose) matrix of M0
  Vc - reference gravity vector
  C0 - reference rotation matrix
  Ct - inverse (or actually transpose) matrix of C0
  Vz - negative Z-axis vector = { 0, 0, -1 }

Everything above works perfectly.

But there is a problem - by using all formulas above to get the calibrated gravity we will have to first perform the computation of composite matrix for each of the next device attitudes or rotations with usage of the current rotation matrix - that is a way expensive operation.

The purpose is to compute a kind of universal recalibration matrix (R0) that could be used to compute the calibrated gravity (Vx) directly from the current gravity (Vg) with only one multiplication and without being dependant on the current rotation matrix (M0) because this current matrix is already included into the current gravity (Vg), such as:

Vg * R0 = Vx
Vx * Rt = Vg

Just applying reference matrix (C0) to the gravity vector (Vg) doesn't work, so:

Vg * C0 != Vx
Vx * Ct != Vg

That happens because Vg = Vz * Mt translates into Vg = Vz * Ct * Xt thus postmultiplying it with C0 wont give us Xt and the resulting vector will be completely odd.

Is solution possible?


As of now I see the only optimized solution as it seems like the wanted R0 matrix is not possible to compute.

The optimized solution would be to split into 2 parts the following formula:

Vx = Vz * Xt --> Vx = Vz * C0 * Ct * Xt --> Vx = Vz * C0 * Mt

Step 1: premultiply the negative Z-axis vector (Vz) with the calibration reference matrix (C0) at a time the reference is taken or set:

Vp = Vz * C0

Step 2: use the optimized multiplication of a vector by a transposed matrix (when the matrix is not really being transposed) at each frame (upon orientation changes):

Vx = optimized_vector_by_transpose_of_matrix_mutiplication( Vp, M0 )

Although this is not what I really want - it works - there is no need to compute the composite matrix for each frame and the actual amount of operations is exactly same as for a single vector by matrix multiplication.

If anyone find a better/nicer solution - you are welcome :-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜