Representation of a transformation.
Public Member Functions | |
procedure | initialize (transformation, dimension) |
Initialize the transformation to the identity. | |
procedure | compose (transformation, target) |
Compose two transformations. | |
procedure | add_rotation_x (transformation, angle) |
Add a rotation around the x axis. | |
procedure | add_rotation_y (transformation, angle) |
Add a rotation around the y axis. | |
procedure | add_rotation_z (transformation, angle) |
Add a rotation around the z axis. | |
procedure | add_rotation (transformation, axis, angle) |
Add a rotation around a given axis. | |
procedure | add_rotation_cos_sin (transformation, axis, c, s) |
Add a rotation around a given axis. | |
procedure | add_translation (transformation, vector) |
Add a translation. | |
procedure | add_scale_x (transformation, factor) |
Add a scaling factor in direction x. | |
procedure | add_scale_y (transformation, factor) |
Add a scaling factor in direction y. | |
procedure | add_scale_z (transformation, factor) |
Add a scaling factor in direction z. | |
procedure | add_scale (transformation, vector) |
Add a scaling in every direction. | |
procedure | transform_point (transformation, point) |
Apply a transformation to a point. | |
procedure | transform_direction (transformation, direction) |
Apply a transformation to a direction. | |
procedure | inverse_transform_point (transformation, point) |
Apply an inverse transformation to a point. | |
procedure | inverse_transform_direction (transformation, direction) |
Apply an inverse transformation to a direction. | |
Public Attributes | |
double precision, dimension(4, 4) | matrix = reshape([1d0, 0d0, 0d0, 0d0, 0d0, 1d0, 0d0, 0d0, 0d0, 0d0, 1d0, 0d0, 0d0, 0d0, 0d0, 1d0], [4,4]) |
Transformation matrix. | |
double precision, dimension(4, 4) | inverse_matrix = reshape([1d0, 0d0, 0d0, 0d0, 0d0, 1d0, 0d0, 0d0, 0d0, 0d0, 1d0, 0d0, 0d0, 0d0, 0d0, 1d0], [4,4]) |
Inverse of the transformation matrix. | |
integer | dimension = 0 |
Dimension of the transformation matrix. | |
procedure mod_cg_transformation::t_cg_transformation::add_rotation | ( | class(t_cg_transformation), intent(inout) | transformation, |
double precision, dimension(3), intent(in) | axis, | ||
double precision, intent(in) | angle ) |
Compose by a rotation matrix. Refer to the code to see the coefficients. Note that the axis
can be a non-unit vector. It is normalized in the routine. A null axis results in a null rotation, that is the identity matrix.
[in,out] | transformation | transformation that receive the transformation |
[in] | axis | rotation axis which will be normalized |
[in] | angle | angle of rotation in radians |
procedure mod_cg_transformation::t_cg_transformation::add_rotation_cos_sin | ( | class(t_cg_transformation), intent(inout) | transformation, |
double precision, dimension(3), intent(in) | axis, | ||
double precision, intent(in) | c, | ||
double precision, intent(in) | s ) |
Compose by a rotation matrix. Refer to the code to see the coefficients. Note that the axis
can be a non-unit vector. It is normalized in the routine. A null axis results in a null rotation, that is the identity matrix.
[in,out] | transformation | transformation that receive the transformation |
[in] | axis | rotation axis which will be normalized |
[in] | c,s | cosine and sine of the angle of rotation |
procedure mod_cg_transformation::t_cg_transformation::add_rotation_x | ( | class(t_cg_transformation), intent(inout) | transformation, |
double precision, intent(in) | angle ) |
Compose by the following rotation matrix:
!! ┌─────┬─────┬─────┬─────┐ !! │ 1 │ 0 │ 0 │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ c │ -s │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ s │ c │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ 0 │ 0 │ 1 │ !! └─────┴─────┴─────┴─────┘ !!
Where s and c are the sine and the cosine of the angle
.
[in,out] | transformation | transformation that receive the transformation |
[in] | angle | angle of rotation in radians |
procedure mod_cg_transformation::t_cg_transformation::add_rotation_y | ( | class(t_cg_transformation), intent(inout) | transformation, |
double precision, intent(in) | angle ) |
Compose by the following rotation matrix:
!! ┌─────┬─────┬─────┬─────┐ !! │ c │ 0 │ s │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ 1 │ 0 │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ -s │ 0 │ c │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ 0 │ 0 │ 1 │ !! └─────┴─────┴─────┴─────┘ !!
Where s and c are the sine and the cosine of the angle
.
[in,out] | transformation | transformation that receive the transformation |
[in] | angle | angle of rotation in radians |
procedure mod_cg_transformation::t_cg_transformation::add_rotation_z | ( | class(t_cg_transformation), intent(inout) | transformation, |
double precision, intent(in) | angle ) |
Compose by the following rotation matrix:
!! ┌─────┬─────┬─────┬─────┐ !! │ c │ -s │ 0 │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ s │ c │ 0 │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ 0 │ 1 │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ 0 │ 0 │ 1 │ !! └─────┴─────┴─────┴─────┘ !!
Where s and c are the sine and the cosine of the angle
.
[in,out] | transformation | transformation that receive the transformation |
[in] | angle | angle of rotation in radians |
procedure mod_cg_transformation::t_cg_transformation::add_scale | ( | class(t_cg_transformation), intent(inout) | transformation, |
double precision, dimension(:), intent(in) | vector ) |
Compose by the following translation matrix:
!! ┌─────┬─────┬─────┬─────┐ !! │ sx │ 0 │ 0 │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ sy │ 0 │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ 0 │ sz │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ 0 │ 0 │ 1 │ !! └─────┴─────┴─────┴─────┘ !!
Where sx, sy, and sz are the scaling factor in direction x, y, and z.
[in,out] | transformation | transformation that receive the transformation |
[in] | vector | array containing the scaling factors per direction. |
procedure mod_cg_transformation::t_cg_transformation::add_scale_x | ( | class(t_cg_transformation), intent(inout) | transformation, |
double precision, intent(in) | factor ) |
Compose by the following translation matrix:
!! ┌─────┬─────┬─────┬─────┐ !! │ sx │ 0 │ 0 │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ 1 │ 0 │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ 0 │ 1 │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ 0 │ 0 │ 1 │ !! └─────┴─────┴─────┴─────┘ !!
Where sx is the scale factor in the direction x.
[in,out] | transformation | transformation that receive the transformation |
[in] | factor | scaling factor in direction x. |
procedure mod_cg_transformation::t_cg_transformation::add_scale_y | ( | class(t_cg_transformation), intent(inout) | transformation, |
double precision, intent(in) | factor ) |
Compose by the following translation matrix:
!! ┌─────┬─────┬─────┬─────┐ !! │ 1 │ 0 │ 0 │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ sy │ 0 │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ 0 │ 1 │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ 0 │ 0 │ 1 │ !! └─────┴─────┴─────┴─────┘ !!
Where sy is the scale factor in the direction y.
[in,out] | transformation | transformation that receive the transformation |
[in] | factor | scaling factor in direction y. |
procedure mod_cg_transformation::t_cg_transformation::add_scale_z | ( | class(t_cg_transformation), intent(inout) | transformation, |
double precision, intent(in) | factor ) |
Compose by the following translation matrix:
!! ┌─────┬─────┬─────┬─────┐ !! │ 1 │ 0 │ 0 │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ 1 │ 0 │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ 0 │ sz │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ 0 │ 0 │ 1 │ !! └─────┴─────┴─────┴─────┘ !!
Where sz is the scale factor in the direction z.
[in,out] | transformation | transformation that receive the transformation |
[in] | factor | scaling factor in direction z. |
procedure mod_cg_transformation::t_cg_transformation::add_translation | ( | class(t_cg_transformation), intent(inout) | transformation, |
double precision, dimension(:), intent(in) | vector ) |
Compose by the following translation matrix:
!! ┌─────┬─────┬─────┬─────┐ !! │ 1 │ 0 │ 0 │ tx │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ 1 │ 0 │ ty │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ 0 │ 1 │ tz │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ 0 │ 0 │ 1 │ !! └─────┴─────┴─────┴─────┘ !!
Where tx, ty, tz are the coordinates of the translation vector
.
[in,out] | transformation | transformation that receive the transformation |
[in] | vector | translation vector |
procedure mod_cg_transformation::t_cg_transformation::compose | ( | class(t_cg_transformation), intent(in) | transformation, |
type(t_cg_transformation), intent(inout) | target ) |
Add a transformation to an other. Perform a matrix-matrix product.
[in] | transformation | transformation to add |
[in,out] | target | transformation that receive the transformation |
procedure mod_cg_transformation::t_cg_transformation::initialize | ( | class(t_cg_transformation), intent(inout) | transformation, |
integer, intent(in) | dimension ) |
The initialization results in the following matrix:
!! ┌─────┬─────┬─────┬─────┐ !! │ 1 │ 0 │ 0 │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ 1 │ 0 │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ 0 │ 1 │ 0 │ !! ├─────┼─────┼─────┼─────┤ !! │ 0 │ 0 │ 0 │ 1 │ !! └─────┴─────┴─────┴─────┘ !!
[in,out] | transformation | transformation |
[in] | dimension | spatial dimension |
procedure mod_cg_transformation::t_cg_transformation::inverse_transform_direction | ( | class(t_cg_transformation), intent(in) | transformation, |
double precision, dimension(:), intent(in) | direction ) |
Return the transformed direction.
[in] | transformation | transformation |
[in] | direction | direction to transform |
procedure mod_cg_transformation::t_cg_transformation::inverse_transform_point | ( | class(t_cg_transformation), intent(in) | transformation, |
double precision, dimension(:), intent(in) | point ) |
Return the transformed point.
[in] | transformation | transformation |
[in] | point | point to transform |
procedure mod_cg_transformation::t_cg_transformation::transform_direction | ( | class(t_cg_transformation), intent(in) | transformation, |
double precision, dimension(:), intent(in) | direction ) |
Return the transformed direction.
[in] | transformation | transformation |
[in] | direction | direction to transform |
procedure mod_cg_transformation::t_cg_transformation::transform_point | ( | class(t_cg_transformation), intent(in) | transformation, |
double precision, dimension(:), intent(in) | point ) |
Return the transformed point.
[in] | transformation | transformation |
[in] | point | point to transform |