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

SecondLife::Rotation - Second Life's rotations (quarterions with a non-standard representation)

VERSION

version 0.900

SYNOPSIS

use SecondLife::DataTypes qw( slrot slvec );

my $rot1 = SecondLife::Rotation->new( "<0,0,0,1>" ); # create a null rotation
my $rot2 = slrot "<0,0,0,1>";                                   # the same
my $rot3 = SecondLife::Rotation->new( x=>0, y=>0, z=>0, s=>1 ); # the same
my $rot4 = SecondLife::Rotation->new( Math::Quaternion->new( 1, 0, 0, 0 ) ); # The same

# Rotate the specified vector by the rotation and return the new vector
my $vec = $rot1->rotate_vector( slvec "<1,2,3>" ); 

print "$rot1\n"; # Prints <0, 0, 0, 1>

DESCRIPTION

This is a subclass of Math::Quaternion. The constructor can accept the Second Life string representation of a rotation, x, y, z, s key/value pairs, a hashref to be passed to Math::Quaternion->new, or a Math::Quaternion object.

Stringifying produces the SecondLife form, not the Math::Quaternion form.

Rotate_vector expects and returns a SecondLife::Vector object.

There are x, y, z, and s accessors.

Otherwise, this is the same as a Math::Quaternion object. If you want to know more about the operations available to, please see its documentation.

CONSTRUCTOR

new( Str $slrotation ) returns SecondLife::Rotation

new( :$x, :$y, :$z, :$s ) returns SecondLife::Rotation

new( Math::Quaternion $quaternion ) returns SecondLife::Rotation

new( HashRef $args ) returns SecondLife::Rotation

Construct a SecondLife::Rotation object from either the SL string representation, or a hash with keys for the individual elements, or a Math::Quaternion object, or a hashref to pass to Math::Quaternion's constructor.

ATTRIBUTES

our Num $x is rw

The X value of this rotation.

our Num $y is rw

The Y value of this rotation.

our Num $z is rw

The Z value of this rotation.

our Num $s is rw

The S value of this rotation.

METHODS

stringify() returns Str

Returns the Second Life string representation of this rotation

rotate_vector( SecondLife::Vector $vector ) returns SecondLife::Vector

Rotates $vector by this rotation and returns the resulting vector. This does not mutate.

SEE ALSO

Please see those modules/websites for more information related to this module.

AUTHOR

Rebecca Turner <becca@referencethis.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Rebecca Turner.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

DISCLAIMER OF WARRANTY

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.