2 SPDX-License-Identifier: BSD-3-Clause
3 Copyright Contributors to the OpenEXR Project.
14 The Imath library emphasizes simplicity, ease of use, correctness and
15 verifiability, performance, and breadth of adoption. Imath is not
16 intended to be a comprehensive linear algebra or numerical analysis
19 Imath is not a substitute for `Eigen <https://eigen.tuxfamily.org>`_!
20 It's not a full-featured linear algebra package, and it doesn't
21 represent vectors and matrices of arbitrary dimension. Its greatest
22 utility is as a geometric data representation, primarily for 2D images
23 and 3D scenes and coordinate transformations, along with an
24 accompanying set of utility methods and functions.
31 .. literalinclude:: examples/intro.cpp
33 Matrices Are Row-Major
34 ======================
36 Imath stores matrices in row-major layout, originally inspired by
37 compatibility with OpenGL matrices.
39 A matrix described as:
43 m_{00} & m_{01} & m_{02} & m_{03} \\
44 m_{10} & m_{11} & m_{12} & m_{13} \\
45 m_{20} & m_{21} & m_{22} & m_{23} \\
46 m_{30} & m_{31} & m_{32} & m_{33} \\
49 is laid out in memory as:
52 :widths: 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
88 A matrix representing a homogeneous transform has a right-hand column
89 of :math:`\begin{bmatrix} 0 & 0 & 0 & 1\end{bmatrix}` and the
90 translation component across the bottom row.
92 As a result, it is best to think of Imath vectors as row-vectors, and
93 vector-matrix multiplication with the vector on the left and matrix on
97 \begin{bmatrix} v_{0}' & v_{1}' & v_{2}' & 1' \end{bmatrix}
99 \begin{bmatrix} v_{0} & v_{1} & v_{2} & 1 \end{bmatrix}
100 \begin{bmatrix} m_{00} & m_{01} & m_{02} & 0 \\
101 m_{10} & m_{11} & m_{12} & 0 \\
102 m_{20} & m_{21} & m_{22} & 0 \\
103 m_{30} & m_{31} & m_{32} & 1
106 This further implies that you should interpret local transformations
107 as pre-multiplication:
112 M.translate (tx, ty, tz);
118 m_{00} & m_{01} & m_{02} & m_{03} \\
119 m_{10} & m_{11} & m_{12} & m_{13} \\
120 m_{20} & m_{21} & m_{22} & m_{23} \\
121 m_{30} & m_{31} & m_{32} & m_{33} \\
132 0 & \cos(r) & \sin(r) & 0 \\
133 0 & -\sin(r) & \cos(r) & 0 \\