# Geometric Foundations

### Geometric Foundations

Understanding how to represent the position and orientation of objects and robots in space is fundamental to robotics. This involves defining coordinate frames and understanding how to transform representations between them.

| Topic                                        | Description & Key Concepts                                                                                                                                                                                                                                                                                                                                                                                                       | Key Equations / Representations                                                                                                                                                                                                                                                                                                                                                  |
| -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Representing Position                        | A point P in space can be described by a vector $${}^A\mathbf{P}$$ originating from the origin of a coordinate frame {A} to point P. This vector has components along the axes of {A}.                                                                                                                                                                                                                                           | $${}^A\mathbf{P} = \begin{bmatrix} p\_x \ p\_y \ p\_z \end{bmatrix}$$                                                                                                                                                                                                                                                                                                            |
| Representing Orientation (Rotation Matrices) | The orientation of a frame {B} relative to a frame {A} can be represented by a 3x3 rotation matrix $${}^A\_B R$$. The columns of $${}^A\_B R$$ are the unit vectors of {B}'s axes expressed in {A}. Rotation matrices are orthogonal ( $$R^T R = I$$) and have a determinant of +1.                                                                                                                                              | $${}^A\_B R = \begin{bmatrix} {}^A\hat{\mathbf{X}}*B & {}^A\hat{\mathbf{Y}}*B & {}^A\hat{\mathbf{Z}}*B \end{bmatrix} = \begin{bmatrix} r*{11} & r*{12} & r*{13} \ r\_{21} & r\_{22} & r\_{23} \ r\_{31} & r\_{32} & r\_{33} \end{bmatrix} Inverse: ({}^A\_B R)^{-1} = ({}^A\_B R)^T = {}^B\_A R$$                                                                                |
| Basic Rotations                              | Rotations about principal axes X, Y, Z by an angle $$\theta$$.                                                                                                                                                                                                                                                                                                                                                                   | $$R\_X(\theta) = \begin{bmatrix} 1 & 0 & 0 \ 0 & c\theta & -s\theta \ 0 & s\theta & c\theta \end{bmatrix}, R\_Y(\theta) = \begin{bmatrix} c\theta & 0 & s\theta \ 0 & 1 & 0 \ -s\theta & 0 & c\theta \end{bmatrix}, R\_Z(\theta) = \begin{bmatrix} c\theta & -s\theta & 0 \ s\theta & c\theta & 0 \ 0 & 0 & 1 \end{bmatrix} (where c\theta = \cos\theta, s\theta = \sin\theta)$$ |
| Mapping Between Frames (Rotation Only)       | A point $${}^B\mathbf{P}$$ expressed in frame {B} can be expressed in frame {A} using                                                                                                                                                                                                                                                                                                                                            | $${}^A\mathbf{P} = {}^A\_B R {}^B\mathbf{P}$$                                                                                                                                                                                                                                                                                                                                    |
| Homogeneous Transformations                  | A 4x4 matrix $${}^A\_B T$$ that combines both rotation ( $${}^A\_B R$$) and translation ( $${}^A\mathbf{P}*{B*{ORG}}$$, the position of {B}'s origin in {A}) to transform points from frame {B} to frame {A} using homogeneous coordinates (adding a 1 as the fourth element to position vectors).                                                                                                                               | $${}^A\_B T = \begin{bmatrix} {}^A\_B R & {}^A\mathbf{P}*{B*{ORG}} \ \mathbf{0}^T & 1 \end{bmatrix}$$ Point transformation: $${}^A\mathbf{P}*{homo} = {}^A\_B T {}^B\mathbf{P}*{homo}$$                                                                                                                                                                                          |
| Inverse Homogeneous Transformation           |                                                                                                                                                                                                                                                                                                                                                                                                                                  | $$({}^A\_B T)^{-1} = {}^B\_A T = \begin{bmatrix} ({}^A\_B R)^T & -({}^A\_B R)^T {}^A\mathbf{P}*{B*{ORG}} \ \mathbf{0}^T & 1 \end{bmatrix}$$                                                                                                                                                                                                                                      |
| Composition of Transformations               | If frame {C} is known relative to {B} ( $${}^B\_C T$$) and {B} relative to {A} ( $${}^A\_B T$$ ), then {C} relative to {A} is                                                                                                                                                                                                                                                                                                    | $${}^A\_C T = {}^A\_B T {}^B\_C T$$ This rule allows chaining transformations through multiple frames.                                                                                                                                                                                                                                                                           |
| Other Orientation Representations            | Euler Angles (e.g., Z-Y-X): Represent orientation as a sequence of three rotations about fixed or moving axes. Can suffer from gimbal lock. Axis-Angle: Orientation as a rotation `\theta` about a unit vector $$\hat{\mathbf{k}}$$. Related to rotation matrix by Rodrigues' Formula. Quaternions: A 4-parameter representation (scalar part and vector part) that avoids gimbal lock and is efficient for composing rotations. | Rodrigues' Formula: $$R\_{\hat{\mathbf{k}},\theta} = I + (\sin\theta)K + (1-\cos\theta)K^2$$, where K is the skew-symmetric matrix of $$\hat{\mathbf{k}}$$. Quaternion for rotation `\theta` about  $$\hat{\mathbf{n}}: Q = \[\cos(\theta/2), n\_x\sin(\theta/2), n\_y\sin(\theta/2), n\_z\sin(\theta/2)]$$                                                                      |
| Transformation of Free Vectors               | Free vectors (e.g., velocity, force) only transform by rotation:                                                                                                                                                                                                                                                                                                                                                                 | $${}^A\mathbf{N} = {}^A\_B R {}^B\mathbf{N}$$ Uses only the 3x3 rotation submatrix of the homogeneous transformation.                                                                                                                                                                                                                                                            |
