The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Vector::Object3D::Matrix::Transform - construction of graphical transformation matrices

SYNOPSIS

package Vector::Object3D::Matrix;

use Readonly;
Readonly my $pi => 3.14159;

use Moose;
with 'Vector::Object3D::Matrix::Transform';

# Calling any method from this role results in creating an instance of the given class:
my $class = 'Vector::Object3D::Matrix';

# Construct rotation matrix on a 2D plane:
my $rotateMatrix2D = $class->get_rotation_matrix(
  rotate_xy => (30 * $pi / 180),
);

# Construct scaling matrix on a 2D plane:
my $scaleMatrix2D = $class->get_scaling_matrix(
  scale_x => 2,
  scale_y => 2,
);

# Construct translation matrix on a 2D plane:
my $translateMatrix2D = $class->get_translation_matrix(
  shift_x => -2,
  shift_y => 1,
);

# Construct rotation matrix in a 3D space:
my $rotateMatrix3D = $class->get_rotation_matrix(
  rotate_xy => (30 * $pi / 180),
  rotate_yz => -30 * ($pi / 180),
  rotate_xz => 45 * ($pi / 180),
);

# Construct scaling matrix in a 3D space:
my $scaleMatrix3D = $class->get_scaling_matrix(
  scale_x => 2,
  scale_y => 2,
  scale_z => 3,
);

# Construct translation matrix in a 3D space:
my $translateMatrix3D = $class->get_translation_matrix(
  shift_x => -2,
  shift_y => 1,
  shift_z => 3,
);

DESCRIPTION

Vector::Object3D::Matrix::Transform is a Moose role that is meant to be applied to Vector::Object3D::Matrix class in order to provide it with additional methods supporting construction of graphical transformation matrices, which currently handle rotation, scaling and translation functionalities.

METHODS

get_rotation_matrix

Construct rotation matrix on a 2D plane:

my $rotateMatrix2D = $class->get_rotation_matrix(
  rotate_xy => (30 * $pi / 180),
);

Construct rotation matrix in a 3D space:

my $rotateMatrix3D = $class->get_rotation_matrix(
  rotate_xy => (30 * $pi / 180),
  rotate_yz => -30 * ($pi / 180),
  rotate_xz => 45 * ($pi / 180),
);

get_scaling_matrix

Construct scaling matrix on a 2D plane:

my $scaleMatrix2D = $class->get_scaling_matrix(
  scale_x => 2,
  scale_y => 2,
);

Construct scaling matrix in a 3D space:

my $scaleMatrix3D = $class->get_scaling_matrix(
  scale_x => 2,
  scale_y => 2,
  scale_z => 3,
);

get_translation_matrix

Construct translation matrix on a 2D plane:

my $translateMatrix2D = $class->get_translation_matrix(
  shift_x => -2,
  shift_y => 1,
);

Construct translation matrix in a 3D space:

my $translateMatrix3D = $class->get_translation_matrix(
  shift_x => -2,
  shift_y => 1,
  shift_z => 3,
);

BUGS

There are no known bugs at the moment. Please report any bugs or feature requests.

EXPORT

Vector::Object3D::Matrix::Transform exports nothing neither by default nor explicitly.

SEE ALSO

Math::VectorReal, Vector::Object3D::Matrix.

AUTHOR

Pawel Krol, <pawelkrol@cpan.org>.

VERSION

Version 0.01 (2012-12-24)

COPYRIGHT AND LICENSE

Copyright (C) 2012 by Pawel Krol.

This library is free open source software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.

PLEASE NOTE THAT IT COMES WITHOUT A WARRANTY OF ANY KIND!