pbpt
Loading...
Searching...
No Matches
pbpt::math::Transform Class Reference

A namespace for 3D transformation factory functions. More...

#include <transform.hpp>

Public Member Functions

constexpr Transform (const Mat4 &mat)
constexpr const Mat4mat () const
constexpr Transformoperator*= (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.

Detailed Description

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.

Member Function Documentation

◆ look_at()

constexpr Transform pbpt::math::Transform::look_at ( const Pt3 & eye,
const Pt3 & target,
const Vec3 & up )
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.

Parameters
eyeThe position of the camera in world space.
targetThe point in world space that the camera is looking at.
upA vector indicating the "up" direction of the world (usually (0, 1, 0)).
Returns
A Mat4 representing the view transformation.

◆ operator*() [1/3]

Normal3 pbpt::math::Transform::operator* ( const Normal3 & normal) const
inlineconstexprnoexcept

Transforms a normal using the transform matrix.

Parameters
normalThe normal to transform.
Returns
The transformed normal.

◆ operator*() [2/3]

Pt3 pbpt::math::Transform::operator* ( const Pt3 & point) const
inlineconstexprnoexcept

Transforms a point using the transform matrix.

Parameters
pointThe point to transform.
Returns
The transformed point.

◆ operator*() [3/3]

Vec3 pbpt::math::Transform::operator* ( const Vec3 & vec) const
inlineconstexprnoexcept

Transforms a vector using the transform matrix.

Parameters
vecThe vector to transform.
Returns
The transformed vector.

◆ orthographic()

constexpr Transform pbpt::math::Transform::orthographic ( Float left,
Float right,
Float bottom,
Float top,
Float z_near,
Float z_far )
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.

Parameters
leftThe x-coordinate of the left clipping plane.
rightThe x-coordinate of the right clipping plane.
bottomThe y-coordinate of the bottom clipping plane.
topThe y-coordinate of the top clipping plane.
z_nearThe z-coordinate of the near clipping plane.
z_farThe z-coordinate of the far clipping plane.
Returns
A Mat4 representing the orthographic projection.

◆ perspective()

constexpr Transform pbpt::math::Transform::perspective ( Float fov_y_rad,
Float aspect_ratio,
Float z_near,
Float z_far )
inlinestaticconstexprnoexcept

Creates a left-handed perspective projection matrix.

This matrix transforms coordinates from view space to clip space, creating the illusion of depth.

Parameters
fov_y_radVertical field of view, in radians.
aspect_ratioThe aspect ratio of the viewport (width / height).
z_nearDistance to the near clipping plane (must be positive).
z_farDistance to the far clipping plane (must be positive and > z_near).
Returns
A Mat4 representing the perspective projection.

◆ rotate()

constexpr Transform pbpt::math::Transform::rotate ( Float angle_rad,
const Vec3 & axis )
inlinestaticconstexprnoexcept

Creates a rotation matrix from an arbitrary axis and an angle (Rodrigues' rotation formula).

Parameters
angle_radThe rotation angle in radians.
axisThe axis of rotation. Should be a unit vector for correct results.
Returns
A Mat4 that performs the specified rotation.

◆ rotate_x()

constexpr Transform pbpt::math::Transform::rotate_x ( Float angle_rad)
inlinestaticconstexprnoexcept

Creates a 4x4 rotation matrix around the X-axis.

Parameters
angle_radThe rotation angle in radians.
Returns
A Mat4 that rotates points/vectors around the world's X-axis.

◆ rotate_y()

constexpr Transform pbpt::math::Transform::rotate_y ( Float angle_rad)
inlinestaticconstexprnoexcept

Creates a 4x4 rotation matrix around the Y-axis.

Parameters
angle_radThe rotation angle in radians.
Returns
A Mat4 that rotates points/vectors around the world's Y-axis.

◆ rotate_z()

constexpr Transform pbpt::math::Transform::rotate_z ( Float angle_rad)
inlinestaticconstexprnoexcept

Creates a 4x4 rotation matrix around the Z-axis.

Parameters
angle_radThe rotation angle in radians.
Returns
A Mat4 that rotates points/vectors around the world's Z-axis.

◆ scale() [1/2]

constexpr Transform pbpt::math::Transform::scale ( const Vec3 & s)
inlinestaticconstexprnoexcept

Creates a 4x4 non-uniform scaling matrix.

Parameters
sA Vec3 containing the scaling factors for the x, y, and z axes.
Returns
A Mat4 that scales a point or vector non-uniformly.

◆ scale() [2/2]

constexpr Transform pbpt::math::Transform::scale ( Float s)
inlinestaticconstexprnoexcept

Creates a 4x4 uniform scaling matrix.

Parameters
sThe scalar factor to scale by on all axes.
Returns
A Mat4 that scales a point or vector uniformly.

◆ translate()

constexpr Transform pbpt::math::Transform::translate ( const Vec3 & t)
inlinestaticconstexprnoexcept

Creates a 4x4 translation matrix.

Parameters
tA Vec3 representing the translation amounts (tx, ty, tz).
Returns
A Mat4 that translates a point by the given vector.

The documentation for this class was generated from the following file:
  • /Users/jinceyang/Desktop/codebase/pbpt/engine/math/transform.hpp