EasyAR coordinate system
In 3D programs, the definition of the coordinate system is very important. Unless otherwise specified, the following conventions are adopted.
Vectors are all column vectors.
Matrices are all row-major. (OpenGL is column-major)
All coordinate systems use the right-handed coordinate system. (Same as OpenGL)
If a coordinate system has a physical scale, the unit is meters.
The negative Y-axis of the world coordinate system is the direction of gravity.
The X-axis of the device coordinate system points to the right, the Y-axis points upward, and the Z-axis points outward from the screen. For devices with rotatable screens, the definitions of right and up are based on their default orientation. Specifically, Android's default orientation follows the system definition. (Glasses and some tablets are placed in landscape mode by default, while phones and some tablets are placed in portrait mode by default.) iOS's default orientation is portrait mode. (Consistent with the definitions in the IMU descriptions of Android and iOS)
Pose of object tracking
The object pose for planar image tracking (ImageTracker) and 3D object tracking (ObjectTracker) is stored in pose, representing the pose of the currently tracked target relative to the camera. Both the camera coordinate system and the target coordinate system are right-handed coordinate systems. The origin of the camera coordinate system is the optical center of the camera, with the positive x-axis pointing to the right, the positive y-axis pointing upward, and the positive z-axis pointing in the direction of light entering the camera (out of the screen). (The right and up directions refer to the right and up in the camera image, which may differ from the device's natural orientation.) The data is arranged in row-major order, opposite to OpenGL's column-major order.
The pose can be written as:
If the 3D engine uses a different coordinate axis definition, the transformation matrix in the 3D engine needs to be adjusted accordingly. For example, if both the camera coordinate system and the target coordinate system have opposite z-axis directions, the transformation matrix of the target node in the 3D engine should be set to:
Transform for motion tracking
The transform of surface tracking (SurfaceTracker) and the cameraTransform of motion tracking (MotionTrackerCameraDevice), ARKit (ARKitCameraDevice), and ARCore (ARCoreCameraDevice) represent the transformation of the camera relative to the world coordinate system. Both the camera coordinate system and the world coordinate system are right-handed coordinate systems. The origin of the camera coordinate system is the optical center of the camera, the positive x-axis points to the right, the positive y-axis points upward, and the positive z-axis points in the direction of light entering the camera (out of the screen). (The right and up directions refer to the natural orientation of the device on mobile devices.) The y-axis of the world coordinate system points upward (opposite to the direction of gravity), and the origin is determined by the motion tracking system. The data is arranged in row-major order, which is the opposite of OpenGL's column-major order.
Sparse spatial map and pose in mega
The getMapPose in the sparse spatial map SparseSpatialMap and the pose in Mega represent the position and orientation of the map block in the camera coordinate system. Both the camera coordinate system and the map block coordinate system are right-handed coordinate systems. The origin of the camera coordinate system is the camera's optical center, with the positive x-axis pointing to the right, the positive y-axis pointing upward, and the positive z-axis pointing in the direction of light entering the camera (out of the screen). (Here, "right" and "up" refer to the natural orientation of the device on mobile devices.) The y-axis of the map block coordinate system points upward (opposite to the direction of gravity), and the origin is determined by the map block data. The data arrangement is row-major, which is opposite to OpenGL's column-major.