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 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( 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.

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

# AUTHOR

Rebecca Turner <becca@referencethis.com>