searches the current version of every section · esc to close

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

21 Scene

21.01 Scene and Coordinate type

A scene is a vector space 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 that 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}\}. A coordinate projected onto the ground plane can therefore be specified by a 2-tuple (x,y)(x, y), referred to as the ground plane coordinate.

On a plane in the scene, a point can be expressed as a 2-tuple (u,v)(u, v) with respect to a given orthonormal basis u^\hat u and v^\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

type Coordinate2D = [number, number]

where the two numbers correspond to uu and vv, in that order. One can therefore use Coordinate2D to express points in the ground plane using the basis u^=x^\hat u = \hat x and v^=y^\hat v = \hat y.

For a plane in the scene, the up direction is defined as n^=u^×v^\hat n = \hat u \times \hat v, where ×\times is the usual cross product and u^\hat u and v^\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 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.

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

type Euler2D = number

where a positive Euler2D value means counterclockwise rotation.

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.