pbpt
|
A namespace for 3D transformation factory functions. More...
#include <transform.hpp>
Public Member Functions | |
constexpr | Transform (const Mat4 &mat) |
constexpr const Mat4 & | mat () const |
constexpr Transform & | operator*= (const Transform &rhs) noexcept |
constexpr Transform | operator* (const Transform &rhs) const noexcept |
constexpr Pt3 | operator* (const Pt3 &point) const noexcept |
Transforms a point using the transform matrix. | |
constexpr Vec3 | operator* (const Vec3 &vec) const noexcept |
Transforms a vector using the transform matrix. | |
constexpr Normal3 | operator* (const Normal3 &normal) const noexcept |
Transforms a normal using the transform matrix. | |
constexpr Ray3 | operator* (const Ray3 &ray) const noexcept |
constexpr Bound3 | operator* (const Bound3 &bound) const noexcept |
Static Public Member Functions | |
static constexpr Transform | translate (const Vec3 &t) noexcept |
Creates a 4x4 translation matrix. | |
static constexpr Transform | scale (Float s) noexcept |
Creates a 4x4 uniform scaling matrix. | |
static constexpr Transform | scale (const Vec3 &s) noexcept |
Creates a 4x4 non-uniform scaling matrix. | |
static constexpr Transform | rotate_x (Float angle_rad) noexcept |
Creates a 4x4 rotation matrix around the X-axis. | |
static constexpr Transform | rotate_y (Float angle_rad) noexcept |
Creates a 4x4 rotation matrix around the Y-axis. | |
static constexpr Transform | rotate_z (Float angle_rad) noexcept |
Creates a 4x4 rotation matrix around the Z-axis. | |
static constexpr Transform | rotate (Float angle_rad, const Vec3 &axis) noexcept |
Creates a rotation matrix from an arbitrary axis and an angle (Rodrigues' rotation formula). | |
static constexpr Transform | look_at (const Pt3 &eye, const Pt3 &target, const Vec3 &up) noexcept |
Creates a view matrix (a.k.a. camera matrix) using the "look-at" method. | |
static constexpr Transform | perspective (Float fov_y_rad, Float aspect_ratio, Float z_near, Float z_far) noexcept |
Creates a left-handed perspective projection matrix. | |
static constexpr Transform | orthographic (Float left, Float right, Float bottom, Float top, Float z_near, Float z_far) noexcept |
Creates a left-handed orthographic projection matrix. |
A namespace for 3D transformation factory functions.
This namespace contains static functions to generate common 3D transformation matrices. Each function corresponds to a specific transformation (translation, rotation, scaling, etc.) and returns a Mat4 (4x4 matrix) that can be used in 3D rendering or other applications.
|
inlinestaticconstexprnoexcept |
Creates a view matrix (a.k.a. camera matrix) using the "look-at" method.
This matrix transforms coordinates from world space to view (camera) space.
eye | The position of the camera in world space. |
target | The point in world space that the camera is looking at. |
up | A vector indicating the "up" direction of the world (usually (0, 1, 0)). |
Transforms a normal using the transform matrix.
normal | The normal to transform. |
Transforms a point using the transform matrix.
point | The point to transform. |
Transforms a vector using the transform matrix.
vec | The vector to transform. |
|
inlinestaticconstexprnoexcept |
Creates a left-handed orthographic projection matrix.
This matrix transforms coordinates from view space to clip space without any perspective distortion. It maps a rectangular box (view volume) to the canonical view volume [-1, 1]^3.
left | The x-coordinate of the left clipping plane. |
right | The x-coordinate of the right clipping plane. |
bottom | The y-coordinate of the bottom clipping plane. |
top | The y-coordinate of the top clipping plane. |
z_near | The z-coordinate of the near clipping plane. |
z_far | The z-coordinate of the far clipping plane. |
|
inlinestaticconstexprnoexcept |
Creates a left-handed perspective projection matrix.
This matrix transforms coordinates from view space to clip space, creating the illusion of depth.
fov_y_rad | Vertical field of view, in radians. |
aspect_ratio | The aspect ratio of the viewport (width / height). |
z_near | Distance to the near clipping plane (must be positive). |
z_far | Distance to the far clipping plane (must be positive and > z_near). |
|
inlinestaticconstexprnoexcept |
Creates a rotation matrix from an arbitrary axis and an angle (Rodrigues' rotation formula).
angle_rad | The rotation angle in radians. |
axis | The axis of rotation. Should be a unit vector for correct results. |
|
inlinestaticconstexprnoexcept |
Creates a 4x4 rotation matrix around the X-axis.
angle_rad | The rotation angle in radians. |
|
inlinestaticconstexprnoexcept |
Creates a 4x4 rotation matrix around the Y-axis.
angle_rad | The rotation angle in radians. |
|
inlinestaticconstexprnoexcept |
Creates a 4x4 rotation matrix around the Z-axis.
angle_rad | The rotation angle in radians. |
Creates a 4x4 uniform scaling matrix.
s | The scalar factor to scale by on all axes. |