基于MATLAB 链接的相机校准外在矩阵应该是 4x3 矩阵(包括方向和平移)意味着我们需要 12 个元素,但是,根据Tango 文档中的解释,我们只得到 3 个平移数字和 4 个旋转数字。如何用这 7 个数字创建 4x3 矩阵?
谢谢,瓦希德。
视图矩阵用于保存这些值。它是一个 4x4 矩阵,允许操纵 3D 姿势(位置 + 方向)。
您可以在此处找到有关此矩阵的更多详细信息: http ://www.3dgep.com/understanding-the-view-matrix/
请注意,Tango java 库基于 Rajawali 3D 库。您可以在此处查看 MatrixX44 的结构:
特别是,以下方法显示了 7 个值的存储方式。为了更容易阅读,您可以假设比例矢量位于 (1,1,1)
public Matrix4 setAll(@NonNull Vector3 position, @NonNull Vector3 scale, @NonNull Quaternion rotation) {
// Precompute these factors for speed
final double x2 = rotation.x * rotation.x;
final double y2 = rotation.y * rotation.y;
final double z2 = rotation.z * rotation.z;
final double xy = rotation.x * rotation.y;
final double xz = rotation.x * rotation.z;
final double yz = rotation.y * rotation.z;
final double wx = rotation.w * rotation.x;
final double wy = rotation.w * rotation.y;
final double wz = rotation.w * rotation.z;
// Column 0
m[M00] = scale.x * (1.0 - 2.0 * (y2 + z2));
m[M10] = 2.0 * scale.y * (xy - wz);
m[M20] = 2.0 * scale.z * (xz + wy);
m[M30] = 0;
// Column 1
m[M01] = 2.0 * scale.x * (xy + wz);
m[M11] = scale.y * (1.0 - 2.0 * (x2 + z2));
m[M21] = 2.0 * scale.z * (yz - wx);
m[M31] = 0;
// Column 2
m[M02] = 2.0 * scale.x * (xz - wy);
m[M12] = 2.0 * scale.y * (yz + wx);
m[M22] = scale.z * (1.0 - 2.0 * (x2 + y2));
m[M32] = 0;
// Column 3
m[M03] = position.x;
m[M13] = position.y;
m[M23] = position.z;
m[M33] = 1.0;
return this;
}