searches the current version of every section · esc to close

Viewing this section as of v0.1.9 (tagged 2026-04-01). Go to current →

21 Scene

21.01 Scene and Coordinate type

A scene is a vector space of R3\mathbb{R}^3. We fix the right-handed orientation and an orthonormal basis, labeled x^\hat x, y^\hat y, and z^\hat z. A point in the space can be expressed as a 3-tuple (x,y,z)=xx^+yy^+zz^(x, y, z) = x\,\hat x + y\,\hat y + z\,\hat z, where xx, yy, and zz are real numbers.

A Coordinate type represents a point in the scene and is an array of three real numbers. It is represented as

type Coordinate = [number, number, number]

where the three numbers correspond to xx, yy, and zz, in this order.

The ground plane is the subspace of the scene spanned by the basis x^\hat x and y^\hat y, i.e., the set {(x,y,0)  xR,  yR}\{(x, y, 0)\ |\ x \in \mathbb{R},\; y \in \mathbb{R}\}. The up direction is defined as the positive direction of the basis vector z^\hat z.

21.02 Coordinate Transformation

A coordinate transformation with uniform scale in the scene defined above transforms a vector v=(vx,vy,vz)\vec v = (v_x, v_y, v_z) to sRv+ts\, R \, \vec v + \vec t, where RR is a rotation operator, ss is a real number for uniform scale, and t\vec t is the translation of the origin. Such a transformation can therefore be encoded in three pieces of information: translation t\vec t, rotation RR, and scale ss.

21.02.01 Rotation and Euler Type

Rotation can be represented by the type Euler, specifying the Euler angles as a 3-tuple (x,y,z)(x, y, z) in radians. The rotations are applied in the order of the xx-axis, then the yy-axis, then the zz-axis. It can be represented as

type Euler = [number, number, number]

where the three numbers correspond to rotation in radians around the xx-axis, yy-axis, and zz-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.

21.02.02 Scale and Scale Type

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

type Scale = number

21.02.03 Local Coordinate

A coordinate distinct from the scene coordinate, also referred to as the global coordinate, is called a local coordinate. A local coordinate can be defined by the coordinate transformation above with respect to the scene coordinate, or can be specified by the origin of the local coordinate in the scene coordinate along with the transformed basis; see Section TODO: local scene.

21.03 Entity in the scene

Each entity in the scene comes with its own local coordinate, and its placement can therefore be described by the three pieces of information defined in Section 21.02. That is, one starts with the entity's local coordinate coinciding with the scene coordinate, then applies the transformation defined in Section 21.02 to the entity.