21 Scenev0.1.25 → v0.1.26
Changed in v0.1.26 (2026-04-02): add 2D case in section 21 scene
→+17 −3
| v0.1.25 | v0.1.26 | ||
|---|---|---|---|
| 1 | # 21 Scene | 1 | # 21 Scene |
| 2 | 2 | ||
| 3 | ## 21.01 Scene and `Coordinate` type | 3 | ## 21.01 Scene and `Coordinate` type |
| 4 | 4 | ||
| 5 | A scene is a vector space of $\mathbb{R}^3$. We fix the right-handed orientation and an orthonormal basis, labeled $\hat x$, $\hat y$, and $\hat z$. A point in the space can be expressed as a 3-tuple $(x, y, z) = x\,\hat x + y\,\hat y + z\,\hat z$, where $x$, $y$, and $z$ are real numbers. | 5 | A scene is a vector space $\mathbb{R}^3$. We fix the right-handed orientation and an orthonormal basis, labeled $\hat x$, $\hat y$, and $\hat z$. A point in the space can be expressed as a 3-tuple $(x, y, z) = x\,\hat x + y\,\hat y + z\,\hat z$, where $x$, $y$, and $z$ are real numbers. |
| 6 | 6 | ||
| 7 | A `Coordinate` type represents a point in the scene and is an array of three real numbers. It is represented as | 7 | A `Coordinate` type represents a point in the scene and is an array of three real numbers. It is represented as |
| 8 | ```ts | 8 | ```ts |
| 9 | type Coordinate = [number, number, number] | 9 | type Coordinate = [number, number, number] |
| 10 | ``` | 10 | ``` |
| 11 | where the three numbers correspond to $x$, $y$, and $z$, in this order. | 11 | where the three numbers correspond to $x$, $y$, and $z$, in that order. |
| 12 | 12 | ||
| 13 | The ground plane is the subspace of the scene spanned by the basis $\hat x$ and $\hat y$, i.e., the set $\{(x, y, 0)\ |\ x \in \mathbb{R},\; y \in \mathbb{R}\}$. The up direction is defined as the positive direction of the basis vector $\hat z$. | 13 | The ground plane is the subspace of the scene spanned by the basis $\hat x$ and $\hat y$, i.e., the set $\{(x, y, 0)\ |\ x \in \mathbb{R},\; y \in \mathbb{R}\}$. A coordinate projected onto the ground plane can therefore be specified by a 2-tuple $(x, y)$, referred to as the ground plane coordinate. |
| 14 | 14 | ||
| 15 | On a plane in the scene, a point can be expressed as a 2-tuple $(u, v)$ with respect to a given orthonormal basis $\hat u$ and $\hat v$, similar to above. A `Coordinate2D` type represents a point in such a plane and is an array of two real numbers. It is represented as | ||
| 16 | ```ts | ||
| 17 | type Coordinate2D = [number, number] | ||
| 18 | ``` | ||
| 19 | where the two numbers correspond to $u$ and $v$, in that order. One can therefore use `Coordinate2D` to express points in the ground plane using the basis $\hat u = \hat x$ and $\hat v = \hat y$. | ||
| 20 | |||
| 21 | For a plane in the scene, the up direction is defined as $\hat n = \hat u \times \hat v$, where $\times$ is the usual cross product and $\hat u$ and $\hat v$ are the orthonormal basis vectors mentioned above. The up direction of the scene is the up direction of the ground plane, i.e., the positive direction of the basis vector $\hat z$. | ||
| 22 | |||
| 15 | ## 21.02 Coordinate Transformation | 23 | ## 21.02 Coordinate Transformation |
| 16 | 24 | ||
| 17 | A coordinate transformation with uniform scale in the scene defined above transforms a vector $\vec v = (v_x, v_y, v_z)$ to $s\, R \, \vec v + \vec t$, where $R$ is a rotation operator, $s$ is a real number for uniform scale, and $\vec t$ is the translation of the origin. Such a transformation can therefore be encoded in three pieces of information: translation $\vec t$, rotation $R$, and scale $s$. | 25 | A coordinate transformation with uniform scale in the scene defined above transforms a vector $\vec v = (v_x, v_y, v_z)$ to $s\, R \, \vec v + \vec t$, where $R$ is a rotation operator, $s$ is a real number for uniform scale, and $\vec t$ is the translation of the origin. Such a transformation can therefore be encoded in three pieces of information: translation $\vec t$, rotation $R$, and scale $s$. |
| 18 | 26 | ||
| 19 | ### 21.02.01 Rotation and `Euler` Type | 27 | ### 21.02.01 Rotation and `Euler` Type |
| 20 | 28 | ||
| 21 | Rotation can be represented by the type `Euler`, specifying the Euler angles as a 3-tuple $(x, y, z)$ in radians. The rotations are applied in the order of the $x$-axis, then the $y$-axis, then the $z$-axis. It can be represented as | 29 | Rotation can be represented by the type `Euler`, specifying the Euler angles as a 3-tuple $(x, y, z)$ in radians. The rotations are applied in the order of the $x$-axis, then the $y$-axis, then the $z$-axis. It can be represented as |
| 22 | ```ts | 30 | ```ts |
| 23 | type Euler = [number, number, number] | 31 | type Euler = [number, number, number] |
| 24 | ``` | 32 | ``` |
| 25 | where the three numbers correspond to rotation in radians around the $x$-axis, $y$-axis, and $z$-axis, in that order. For each rotation, a positive value means counterclockwise rotation. A zero rotation on all axes implies that the axes of the transformed coordinate align with those of the scene coordinate. | 33 | where the three numbers correspond to rotation in radians around the $x$-axis, $y$-axis, and $z$-axis, in that order. For each rotation, a positive value means counterclockwise rotation. A zero rotation on all axes implies that the axes of the transformed coordinate align with those of the scene coordinate. |
| 26 | 34 | ||
| 35 | Rotation on a plane can also be represented by an Euler angle as a single number. The rotation is applied around the up-axis of the plane. A `Euler2D` represents such data as | ||
| 36 | ```ts | ||
| 37 | type Euler2D = number | ||
| 38 | ``` | ||
| 39 | where a positive `Euler2D` value means counterclockwise rotation. | ||
| 40 | |||
| 27 | ### 21.02.02 Scale and `Scale` Type | 41 | ### 21.02.02 Scale and `Scale` Type |
| 28 | 42 | ||
| 29 | The type `Scale` represents the scaling of the transformed coordinate about its local origin and is a real number, where a value of 1 means no scaling. It can be represented as | 43 | The type `Scale` represents the scaling of the transformed coordinate about its local origin and is a real number, where a value of 1 means no scaling. It can be represented as |