NAME

Vector::Object3D::Point::Transform - Three-dimensional point object transformations

SYNOPSIS

package Vector::Object3D::Point;

use Readonly;
Readonly my $pi => 3.14159;

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

# Calling any method from this role requires providing an object of a base class
# and results in creation of a new instance of the same class:
my $point = Vector::Object3D::Point->new(coord => [3, -2, 1]);

# Rotate point on a 2D plane:
my $rotatePoint2D = $point->rotate(
  rotate_xy => 30 * ($pi / 180),
);

# Scale point on a 2D plane:
my $scalePoint2D = $point->scale(
  scale_x => 2,
  scale_y => 2,
);

# Translate point on a 2D plane:
my $translatePoint2D = $point->translate(
  shift_x => -2,
  shift_y => 1,
);

# Rotate point in a 3D space:
my $rotatePoint3D = $point->rotate(
  rotate_xy => 30 * ($pi / 180),
  rotate_yz => -30 * ($pi / 180),
  rotate_xz => 45 * ($pi / 180),
);

# Scale point in a 3D space:
my $scalePoint3D = $point->scale(
  scale_x => 2,
  scale_y => 2,
  scale_z => 3,
);

# Translate point in a 3D space:
my $translatePoint3D = $point->translate(
  shift_x => -2,
  shift_y => 1,
  shift_z => 3,
);

DESCRIPTION

Vector::Object3D::Point::Transform is a Moose role that is meant to be applied to Vector::Object3D::Point class in order to provide it with additional methods supporting fundamental transformations in the 3D space, such as rotation, scaling and translation.

METHODS

rotate

Rotate point on a 2D plane:

my $rotatePoint2D = $point->rotate(
  rotate_xy => 30 * ($pi / 180),
);

Rotate point in a 3D space:

my $rotatePoint3D = $point->rotate(
  rotate_xy => 30 * ($pi / 180),
  rotate_yz => -30 * ($pi / 180),
  rotate_xz => 45 * ($pi / 180),
);

scale

Scale point on a 2D plane:

my $scalePoint2D = $point->scale(
  scale_x => 2,
  scale_y => 2,
);

Scale point in a 3D space:

my $scalePoint3D = $point->scale(
  scale_x => 2,
  scale_y => 2,
  scale_z => 3,
);

translate

Translate point on a 2D plane:

my $translatePoint2D = $point->translate(
  shift_x => -2,
  shift_y => 1,
);

Translate point in a 3D space:

my $translatePoint3D = $point->translate(
  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::Point::Transform exports nothing neither by default nor explicitly.

SEE ALSO

Vector::Object3D::Point.

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!