# GPS-Induced Disparity Correction for Accurate Object Placement in Augmented Reality
## 2 Materials and Methods
### Localization of 3D Objects  
Understanding the position and orientation of the camera is vital to transform 3D spatial coordinates into 2D image coordinates. This concept is often referred to as the rigid body transformation of a camera. Consider an object located in 3D space, designated by coordinates \(P(x,y,z)\). In AR, the positioning of a virtual object can be estimated using the physical location of the camera and GPS data correlating to a specific real-world location. First, let us consider rigid-body transformation. Conversion of the 3D position into the camera coordinate system involves a series of rotations and translations determined by the camera's accurate positioning and orientation data obtained via GPS. This transformation is essential for precisely locating the camera in space. The 3D coordinates are then projected onto a 2D image plane by utilizing the intrinsic parameters of the camera, such as the focal length and sensor attributes. This projection process generates image coordinates \((x_{\text{pixel}},y_{\text{pixel}})\), indicating the 3D point's horizontal and vertical positions in the 2D image frame. However, in real-world applications, discrepancies in camera positioning, primarily due to GPS inaccuracies, can occur. These discrepancies lead to a scenario in which the rigid-body transformation, now with GPS errors, presents positional deviations. Targeting the same 3D point P, this altered transformation yields a different set of 2D coordinates on the image plane, denoted \((x_{\text{pixel,error}},y_{\text{pixel,error}})\). These coordinates reflect the incorrect projection of the same 3D point, which is attributed to deviations in the rigid-body transformation of the perturbed camera. Comparing \(P^{\prime}\) with \(P^{\prime}_{r}\) reveals the impact of camera positioning errors on the precision of projecting 3D points onto a 2D plane. This insight is particularly crucial in AR for accurate mapping and object localization. The rotation matrix in the context of 3D space is a fundamental aspect of camera characteristics, representing the rotation of an object or coordinate system in three dimensions. Let us now explore the derivation of a 3D rotation  
Figure 2: Illustration of three-point matching for object localization. (**a**) Alignment of object coordinates via GPS coordinates without error using three reference points. (**b**) Potential errors in case of GPS inaccuracies, represented by the thickness of each circle. matrix, commonly denoted as \(R\). In the XYZ coordinate system, rotation can occur around the principal X, Y, and Z axes. These rotations are typically described using Euler angles: roll (\(\phi\)), pitch (\(\theta\)), and yaw (\(\psi\)). The matrices for these rotations are as follows:  
The roll around the X-axis is denoted as  
\[R_{x}(\phi)=\left[ \begin{array}{ccc}1&0&0\\ 0&\cos(\phi)&-\sin(\phi)\\ 0&\sin(\phi)&\cos(\phi)\end{array} \right]. \tag{1}\]  
The pitch around the Y-axis is denoted as  
\[R_{y}(\theta)=\left[ \begin{array}{ccc}\cos(\theta)&0&\sin(\theta)\\ 0&1&0\\ -\sin(\theta)&0&\cos(\theta)\end{array} \right]. \tag{2}\]  
Finally, the yaw around the Z-axis is denoted as  
\[R_{z}(\psi)=\left[ \begin{array}{ccc}\cos(\psi)&-\sin(\psi)&0\\ \sin(\psi)&\cos(\psi)&0\\ 0&0&1\end{array} \right]. \tag{3}\]  
The combined rotation matrix \(R\), representing rotations in the Z-Y-X sequence (i.e., yaw-pitch-roll), is defined as the product of the individual matrices, denoted as (1), (2), and (3), respectively, collectively forming  
\[R_{z}(\psi)\cdot R_{y}(\theta)\cdot R_{x}(\phi) \tag{4}\]  
This matrix is crucial for rotating a point or coordinate frame in 3D space, and the specific multiplication order (Z-Y-X) indicates the non-commutative nature of matrix multiplication in rotations. To compute the rigid-body transformation of a camera in 3D space, both rotation and translation are involved. This transformation is pivotal for mapping points from one coordinate system to another. The detailed process is described next.