geometry

projections

namespace squint
namespace geometry

Functions

template<typename T>
auto ortho(length_t<T> left, length_t<T> right, length_t<T> bottom, length_t<T> top, length_t<T> near_plane, length_t<T> far_plane, length_t<T> unit_length = length_t<T>{1})

Creates an orthographic projection matrix.

This function generates a 4x4 orthographic projection matrix that maps the specified viewing frustum onto a unit cube centered at the origin.

Note

The resulting matrix assumes a right-handed coordinate system.

Template Parameters:

T – The underlying scalar type for the length quantities.

Parameters:
  • left – The left clipping plane coordinate.

  • right – The right clipping plane coordinate.

  • bottom – The bottom clipping plane coordinate.

  • top – The top clipping plane coordinate.

  • near_plane – The near clipping plane distance.

  • far_plane – The far clipping plane distance.

  • unit_length – The unit length for the projection space (default is 1).

Returns:

A 4x4 tensor representing the orthographic projection matrix.

template<dimensionless_scalar T, typename U>
auto perspective(T fovy, T aspect, length_t<U> near_plane, length_t<U> far_plane, length_t<U> unit_length = length_t<U>{1})

Creates a perspective projection matrix.

This function generates a 4x4 perspective projection matrix based on the specified field of view, aspect ratio, and near and far clipping planes.

Note

The resulting matrix assumes a right-handed coordinate system.

Note

The field of view (fovy) should be in radians.

Template Parameters:
  • T – The underlying scalar type for the field of view and aspect ratio.

  • U – The underlying scalar type for the length quantities.

Parameters:
  • fovy – The vertical field of view in radians.

  • aspect – The aspect ratio (width / height) of the viewport.

  • near_plane – The distance to the near clipping plane.

  • far_plane – The distance to the far clipping plane.

  • unit_length – The unit length for the projection space (default is 1).

Returns:

A 4x4 tensor representing the perspective projection matrix.

transformations

namespace squint
namespace geometry

Functions

template<transformation_matrix T, typename U>
void translate(T &matrix, const tensor<length_t<U>, shape<3>> &x, length_t<U> unit_length = length_t<U>{1})

Applies a translation to a transformation matrix.

This function modifies the input transformation matrix by applying a translation.

Template Parameters:
  • T – The type of the transformation matrix.

  • U – The underlying scalar type for the length quantities.

Parameters:
  • matrix – The transformation matrix to modify.

  • x – The translation vector.

  • unit_length – The unit length for the translation (default is 1).

template<transformation_matrix T, dimensionless_scalar U, dimensionless_scalar V>
void rotate(T &matrix, U angle, const tensor<V, shape<3>> &axis)

Applies a rotation to a transformation matrix.

This function modifies the input transformation matrix by applying a rotation around an arbitrary axis.

Template Parameters:
  • T – The type of the transformation matrix.

  • U – The underlying scalar type for the angle.

  • V – The underlying scalar type for the axis.

Parameters:
  • matrix – The transformation matrix to modify.

  • angle – The rotation angle in radians.

  • axis – The rotation axis.

template<transformation_matrix T, dimensionless_scalar U>
void scale(T &matrix, const tensor<U, shape<3>> &s)

Applies a scale transformation to a transformation matrix.

This function modifies the input transformation matrix by applying a scale transformation.

Template Parameters:
  • T – The type of the transformation matrix.

  • U – The underlying scalar type for the scale factors.

Parameters:
  • matrix – The transformation matrix to modify.

  • s – The scale factors for each axis.