searches the current version of every section · esc to close

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.25v0.1.26
1# 21 Scene1# 21 Scene
22
3## 21.01 Scene and `Coordinate` type3## 21.01 Scene and `Coordinate` type
44
5A 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.5A 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.
66
7A `Coordinate` type represents a point in the scene and is an array of three real numbers. It is represented as7A `Coordinate` type represents a point in the scene and is an array of three real numbers. It is represented as
8```ts8```ts
9type Coordinate = [number, number, number]9type Coordinate = [number, number, number]
10```10```
11where the three numbers correspond to $x$, $y$, and $z$, in this order.11where the three numbers correspond to $x$, $y$, and $z$, in that order.
1212
13The 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$.13The 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.
1414
15On 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
17type Coordinate2D = [number, number]
18```
19where 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
21For 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 Transformation23## 21.02 Coordinate Transformation
1624
17A 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$.25A 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$.
1826
19### 21.02.01 Rotation and `Euler` Type27### 21.02.01 Rotation and `Euler` Type
2028
21Rotation 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 as29Rotation 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```ts30```ts
23type Euler = [number, number, number]31type Euler = [number, number, number]
24```32```
25where 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.33where 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.
2634
35Rotation 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
37type Euler2D = number
38```
39where a positive `Euler2D` value means counterclockwise rotation.
40
27### 21.02.02 Scale and `Scale` Type41### 21.02.02 Scale and `Scale` Type
2842
29The 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 as43The 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