scenepic 1.1.0
3D Visualization Made Easy
Functions
scenepic::Transforms Namespace Reference

Functions

Transform scale (float scale)
 Creates a 3D homogeneous scale matrix. More...
 
Transform scale (const Vector &scale)
 Creates a 3D homogeneous scale matrix. More...
 
Transform translate (const Vector &vec)
 Creates a 3D homogeneous scale matrix. More...
 
Transform rotation_matrix_from_axis_angle (const Vector &axis, float angle)
 Creates a 3D homogeneous scale matrix from axis and angle. More...
 
Quaternion quaternion_from_axis_angle (const Vector &axis, float angle)
 Convert rotation axis and angle to a quaternion. More...
 
std::pair< Vector, float > axis_angle_to_align_x_to_axis (const Vector &axis)
 Find the axis and angle of rotation that will ensure the x-axis aligns with the provided axis. More...
 
Quaternion quaternion_to_align_x_to_axis (const Vector &axis)
 Creates a quaternion rotation vector that will ensure the x-axis aligns with the provided axis. More...
 
Quaternion quaternion_multiply (const Quaternion &a, const Quaternion &b)
 Multiply two quaternions. More...
 
Transform rotation_to_align_x_to_axis (const Vector &axis)
 Creates a 3D homogeneous rotation matrix that will ensure the x-axis aligns with the provided axis. More...
 
Transform rotation_about_x (float angle)
 Creates a 3D homogeneous rotation matrix about the x-axis. More...
 
Transform rotation_about_y (float angle)
 Creates a 3D homogeneous rotation matrix about the x-axis. More...
 
Transform rotation_about_z (float angle)
 Creates a 3D homogeneous rotation matrix about the x-axis. More...
 
Transform look_at_rotation (const Vector &center, const Vector &look_at, const Vector &up_dir)
 Creates a 3D homogeneous rotation matrix that will cause an object with the specified center to look at the specified location, with the up direction as given. More...
 
Transform euler_angles_to_matrix (const Vector &euler_angles, const std::string &convention="XYZ")
 Creates a 3D homogeneous rotation matrix from three euler angles using the specified convention. More...
 
Transform quaternion_to_matrix (const Quaternion &quaternion)
 Creates a 3D homogeneous rotation matrix from a quaternion. More...
 
Transform gl_projection (double fov_y_degrees, double aspect_ratio, double znear, double zfar)
 Creates a WebGL projection transform (i.e. More...
 
Transform gl_projection (const Intrinsic &camera_matrix, int width, int height, double znear, double zfar)
 Creates a WebGL projection transform (i.e. More...
 
Transform gl_world_to_camera (const Extrinsic &extrinsic)
 Creates a WebGL view transform (i.e. More...
 

Function Documentation

◆ axis_angle_to_align_x_to_axis()

std::pair< Vector, float > scenepic::Transforms::axis_angle_to_align_x_to_axis ( const Vector &  axis)

Find the axis and angle of rotation that will ensure the x-axis aligns with the provided axis.

NB one degree of freedom is underconstrained.

Parameters
axisthe axis to which to align the x-axis
Returns
a 3D homogeneous transform matrix

◆ euler_angles_to_matrix()

Transform scenepic::Transforms::euler_angles_to_matrix ( const Vector &  euler_angles,
const std::string &  convention = "XYZ" 
)

Creates a 3D homogeneous rotation matrix from three euler angles using the specified convention.

See https://en.wikipedia.org/wiki/Euler_angles for more information on valid conventions. Conventions are specified as a three character string indicating the convention order, with values taken from [X, Y, Z].

Parameters
euler_anglesthe Euler angles to use in constructing the matrix
conventionthe convention to use in interpreting the angles
Returns
a 3D homogeneous transform matrix

◆ gl_projection() [1/2]

Transform scenepic::Transforms::gl_projection ( const Intrinsic &  camera_matrix,
int  width,
int  height,
double  znear,
double  zfar 
)

Creates a WebGL projection transform (i.e.

that goes from view coordinates to NDC) from an OpenCV-style camera matrix.

Parameters
camera_matrixthe OpenCV-style camera matrix
widththe width of the calibration image in pixels
heightthe height of the calibration image in pixels
znearthe z value of the near clipping plane of the frustum
zfarthe z value of the far clipping plane of the frustum
Returns
a WebGL projection matrix

◆ gl_projection() [2/2]

Transform scenepic::Transforms::gl_projection ( double  fov_y_degrees,
double  aspect_ratio,
double  znear,
double  zfar 
)

Creates a WebGL projection transform (i.e.

that goes from view coordinates to NDC).

Parameters
fov_y_degreesthe field of view of the camera in degrees
aspect_ratiothe aspect ratio of the camera
znearthe z value of the near clipping plane of the frustum
zfarthe z value of the far clipping plane of the frustum
Returns
a WebGL projection matrix

◆ gl_world_to_camera()

Transform scenepic::Transforms::gl_world_to_camera ( const Extrinsic &  extrinsic)

Creates a WebGL view transform (i.e.

that goes from world coordinates to camera view coordinates) from an OpenCV-style extrinsic matrix

Parameters
extrinsicthe camera-to-world matrix, which places the camera in the scene
Returns
a WebGL view matrix

◆ look_at_rotation()

Transform scenepic::Transforms::look_at_rotation ( const Vector &  center,
const Vector &  look_at,
const Vector &  up_dir 
)

Creates a 3D homogeneous rotation matrix that will cause an object with the specified center to look at the specified location, with the up direction as given.

Parameters
centerthe center of the object
look_atthe position to look at
up_dirthe direction that is "up"
Returns
a 3D homogeneous transform matrix

◆ quaternion_from_axis_angle()

Quaternion scenepic::Transforms::quaternion_from_axis_angle ( const Vector &  axis,
float  angle 
)

Convert rotation axis and angle to a quaternion.

Parameters
axisthe axis of rotation
anglethe angle to rotate in radians
Returns
a quaternion

◆ quaternion_multiply()

Quaternion scenepic::Transforms::quaternion_multiply ( const Quaternion &  a,
const Quaternion &  b 
)

Multiply two quaternions.

Parameters
athe first quaternion
bthe second quaternion
Returns
the result of a * b

◆ quaternion_to_align_x_to_axis()

Quaternion scenepic::Transforms::quaternion_to_align_x_to_axis ( const Vector &  axis)

Creates a quaternion rotation vector that will ensure the x-axis aligns with the provided axis.

NB one degree of freedom is underconstrained.

Parameters
axisthe axis to which to align the x-axis
Returns
a quaternion

◆ quaternion_to_matrix()

Transform scenepic::Transforms::quaternion_to_matrix ( const Quaternion &  quaternion)

Creates a 3D homogeneous rotation matrix from a quaternion.

Parameters
quaternionthe quaternion to convert
Returns
a 3D homogeneous transform matrix.

◆ rotation_about_x()

Transform scenepic::Transforms::rotation_about_x ( float  angle)

Creates a 3D homogeneous rotation matrix about the x-axis.

Parameters
anglethe angle to rotate in radians
Returns
a 3D homogeneous transform matrix

◆ rotation_about_y()

Transform scenepic::Transforms::rotation_about_y ( float  angle)

Creates a 3D homogeneous rotation matrix about the x-axis.

Parameters
anglethe angle to rotate in radians
Returns
a 3D homogeneous transform matrix

◆ rotation_about_z()

Transform scenepic::Transforms::rotation_about_z ( float  angle)

Creates a 3D homogeneous rotation matrix about the x-axis.

Parameters
anglethe angle to rotate in radians
Returns
a 3D homogeneous transform matrix

◆ rotation_matrix_from_axis_angle()

Transform scenepic::Transforms::rotation_matrix_from_axis_angle ( const Vector &  axis,
float  angle 
)

Creates a 3D homogeneous scale matrix from axis and angle.

Parameters
axisthe axis of rotation
anglethe angle to rotate in radians
Returns
a 3D homogeneous transform matrix

◆ rotation_to_align_x_to_axis()

Transform scenepic::Transforms::rotation_to_align_x_to_axis ( const Vector &  axis)

Creates a 3D homogeneous rotation matrix that will ensure the x-axis aligns with the provided axis.

NB one degree of freedom is underconstrained.

Parameters
axisthe axis to which to align the x-axis
Returns
a 3D homogeneous transform matrix

◆ scale() [1/2]

Transform scenepic::Transforms::scale ( const Vector &  scale)

Creates a 3D homogeneous scale matrix.

Parameters
scalethe axis-specific scale values
Returns
a 3D homogeneous transform matrix

◆ scale() [2/2]

Transform scenepic::Transforms::scale ( float  scale)

Creates a 3D homogeneous scale matrix.

Parameters
scalethe scale to use across all axes
Returns
a 3D homogeneous transform matrix

◆ translate()

Transform scenepic::Transforms::translate ( const Vector &  vec)

Creates a 3D homogeneous scale matrix.

Parameters
vecthe movement vector
Returns
a 3D homogeneous transform matrix