Rand Stats

The uploading author of cpan:JEFFOBER does not match the META author of github:sysread.

Math::Vector3D

cpan:JEFFOBER

NAME

Math::Vector3D

VERSION

0.0.1

SYNOPSIS

use Math::Vector3D;

my $vec = vec(10, 20, 30);

$vec -= $other-vector;
$vec *= 42;
$vec /= 10;

$vec.normalize;

my $len = $vec.length;

SEE ALSO

Has support for any number of dimensions.

class Math::Vector3D

Vector object

has Numeric $.x

Default: 0

has Numeric $.y

Default: 0

has Numeric $.z

Default: 0

method length-squared

method length-squared() returns Numeric

Returns the squared length of the vector

method length

method length() returns Numeric

Returns the length of the vector

multi method add

multi method add(
    Math::Vector3D:D $v
) returns Math::Vector3D

Destructively adds a vector to this vector.

multi method add

multi method add(
    Numeric:D $n
) returns Math::Vector3D

Destructively adds a scalar to this vector.

multi method sub

multi method sub(
    Math::Vector3D:D $v
) returns Math::Vector3D

Destructively subtracts a vector from this vector.

multi method sub

multi method sub(
    Numeric:D $n
) returns Math::Vector3D

Destructively subtracts a scalar from this vector.

multi method mul

multi method mul(
    Math::Vector3D:D $v
) returns Math::Vector3D

Destructively multiplies this vector by another vector.

multi method mul

multi method mul(
    Numeric:D $n
) returns Math::Vector3D

Destructively multiplies this vector by a scalar value.

multi method div

multi method div(
    Math::Vector3D:D $v
) returns Math::Vector3D

Destructively divides this vector by another vector.

multi method div

multi method div(
    Numeric:D $n
) returns Math::Vector3D

Destructively divides this vector by a scalar value.

method negate

method negate() returns Math::Vector3D

Returns a new vector with negated values for x, y, and z.

method cross

method cross(
    Math::Vector3D:D $v
) returns Math::Vector3D

Destructively updates this vector to be the cross product of itself and another vector.

method dot

method dot(
    Math::Vector3D:D $v
) returns Numeric

Computes the dot product of the vector and the supplied number.

method angle-to

method angle-to(
    Math::Vector3D:D $v
) returns Numeric

Computes the angle to the supplied vector.

method distance-to-squared

method distance-to-squared(
    Math::Vector3D:D $v
) returns Numeric

Computes the square of the distance between this vector and the supplied vector.

method distance-to

method distance-to(
    Math::Vector3D:D $v
) returns Numeric

Computes the distance between this vector and the supplied vector.

method normalize

method normalize() returns Math::Vector3D

Destructively normalizes this vector.

method set-length

method set-length(
    Numeric:D $n
) returns Math::Vector3D

Destructively sets the length of the vector.

method lerp

method lerp(
    Math::Vector3D:D $target,
    Numeric:D $n
) returns Math::Vector3D

Lerps toward the target vector by the supplied value.

method List

method List() returns List

Coerces to a List of [x, y, z]

multi sub infix:<+>

multi sub infix:<+>(
    Math::Vector3D:D $v,
    $n
) returns Math::Vector3D

multi sub infix:<->

multi sub infix:<->(
    Math::Vector3D:D $v,
    $n
) returns Math::Vector3D

multi sub infix:<*>

multi sub infix:<*>(
    Math::Vector3D:D $v,
    $n
) returns Math::Vector3D

multi sub infix:</>

multi sub infix:</>(
    Math::Vector3D:D $v,
    $n
) returns Math::Vector3D

/ is overloaded to div

multi sub infix:<==>

multi sub infix:<==>(
    Math::Vector3D:D $v1,
    Math::Vector3D:D $v2
) returns Bool

== is overloaded to compare two vectors' x, y, and z values

multi sub vec

multi sub vec(
    Numeric:D $x = 0,
    Numeric:D $y = 0,
    Numeric:D $z = 0
) returns Math::Vector3D

Syntactic sugar to construct a new vector from three numbers.

multi sub vec

multi sub vec(
    Math::Vector3D:D $v
) returns Math::Vector3D

Syntactic sugar to construct a new vector from another vector (clone).