N-Vec2

#------------------------------------------------------------------------------- #--[Class Description]---------------------------------------------------------- #-------------------------------------------------------------------------------

Gnome::Graphene::N-Vec2

Description

A structure capable of holding a vector with two dimensions, x and y.

The contents of the #graphene_vec2_t structure are private and should never be accessed directly.

#------------------------------------------------------------------------------- #--[Record Structure Documentation]--------------------------------------------- #-------------------------------------------------------------------------------

Record N-Vec2

class N-Vec2:auth<github:MARTIMM>:api<2> is export is repr('CStruct') {
has N-Simd4F _UA_ $.value;
  }
  • value;

#------------------------------------------------------------------------------- #--[Class Initialization]------------------------------------------------------- #-------------------------------------------------------------------------------

Class initialization

new

:native-object

Create an object using a native object from elsewhere. See also Gnome::N::TopLevelSupportClass.

multi method new ( N-Object :$native-object! )

#-------------------------------------------------------------------------------

alloc

Allocates a new #graphene_vec2_t structure.

The contents of the returned structure are undefined.

Use .init() to initialize the vector.

method alloc ( --> Gnome::Graphene::Vec2 \)

#------------------------------------------------------------------------------- #--[Methods]-------------------------------------------------------------------- #-------------------------------------------------------------------------------

Methods

#-------------------------------------------------------------------------------

add

Adds each component of the two passed vectors and places each result into the components of $res.

method add ( CArray[N-Vec2] $b, CArray[N-Vec2] $res )
  • $b; a #graphene_vec2_t.

  • $res; return location for the result.

#-------------------------------------------------------------------------------

divide

Divides each component of the first operand $a by the corresponding component of the second operand $b, and places the results into the vector $res.

method divide ( CArray[N-Vec2] $b, CArray[N-Vec2] $res )
  • $b; a #graphene_vec2_t.

  • $res; return location for the result.

#-------------------------------------------------------------------------------

dot

Computes the dot product of the two given vectors.

method dot ( CArray[N-Vec2] $b --> Num )
  • $b; a #graphene_vec2_t.

Return value; the dot product of the vectors.

#-------------------------------------------------------------------------------

equal This function is not yet available

Checks whether the two given #graphene_vec2_t are equal.

method equal ( CArray[N-Vec2] $v2 )
  • $v2; a #graphene_vec2_t.

#-------------------------------------------------------------------------------

free

Frees the resources allocated by $v

method free ( )

#-------------------------------------------------------------------------------

get-x

Retrieves the X component of the #graphene_vec2_t.

method get-x (--> Num )

Return value; the value of the X component.

#-------------------------------------------------------------------------------

get-y

Retrieves the Y component of the #graphene_vec2_t.

method get-y (--> Num )

Return value; the value of the Y component.

#-------------------------------------------------------------------------------

init

Initializes a #graphene_vec2_t using the given values.

This function can be called multiple times.

method init ( Num() $x, Num() $y --> CArray[N-Vec2] )
  • $x; the X field of the vector.

  • $y; the Y field of the vector.

Return value; the initialized vector.

#-------------------------------------------------------------------------------

init-from-float

Initializes $v with the contents of the given array.

method init-from-float ( Num() $src --> CArray[N-Vec2] )
  • $src; an array of floating point values with at least two elements.

Return value; the initialized vector.

#-------------------------------------------------------------------------------

init-from-vec2

Copies the contents of $src into $v.

method init-from-vec2 ( CArray[N-Vec2] $src --> CArray[N-Vec2] )
  • $src; a #graphene_vec2_t.

Return value; the initialized vector.

#-------------------------------------------------------------------------------

interpolate

Linearly interpolates $v1 and $v2 using the given $factor.

method interpolate ( CArray[N-Vec2] $v2, Num() $factor, CArray[N-Vec2] $res )
  • $v2; a #graphene_vec2_t.

  • $factor; the interpolation factor.

  • $res; the interpolated vector.

#-------------------------------------------------------------------------------

length

Computes the length of the given vector.

method length (--> Num )

Return value; the length of the vector.

#-------------------------------------------------------------------------------

max

Compares the two given vectors and places the maximum values of each component into $res.

method max ( CArray[N-Vec2] $b, CArray[N-Vec2] $res )
  • $b; a #graphene_vec2_t.

  • $res; the resulting vector.

#-------------------------------------------------------------------------------

min

Compares the two given vectors and places the minimum values of each component into $res.

method min ( CArray[N-Vec2] $b, CArray[N-Vec2] $res )
  • $b; a #graphene_vec2_t.

  • $res; the resulting vector.

#-------------------------------------------------------------------------------

multiply

Multiplies each component of the two passed vectors and places each result into the components of $res.

method multiply ( CArray[N-Vec2] $b, CArray[N-Vec2] $res )
  • $b; a #graphene_vec2_t.

  • $res; return location for the result.

#-------------------------------------------------------------------------------

near This function is not yet available

Compares the two given #graphene_vec2_t vectors and checks whether their values are within the given $epsilon.

method near ( CArray[N-Vec2] $v2, Num() $epsilon )
  • $v2; a #graphene_vec2_t.

  • $epsilon; the threshold between the two vectors.

#-------------------------------------------------------------------------------

negate

Negates the given #graphene_vec2_t.

method negate ( CArray[N-Vec2] $res )
  • $res; return location for the result vector.

#-------------------------------------------------------------------------------

normalize

Computes the normalized vector for the given vector $v.

method normalize ( CArray[N-Vec2] $res )
  • $res; return location for the normalized vector.

#-------------------------------------------------------------------------------

scale

Multiplies all components of the given vector with the given scalar $factor.

method scale ( Num() $factor, CArray[N-Vec2] $res )
  • $factor; the scalar factor.

  • $res; return location for the result vector.

#-------------------------------------------------------------------------------

subtract

Subtracts from each component of the first operand $a the corresponding component of the second operand $b and places each result into the components of $res.

method subtract ( CArray[N-Vec2] $b, CArray[N-Vec2] $res )
  • $b; a #graphene_vec2_t.

  • $res; return location for the result.

#-------------------------------------------------------------------------------

to-float

Stores the components of $v into an array.

method to-float ( Num() $dest )
  • $dest; return location for an array of floating point values with at least 2 elements.

#------------------------------------------------------------------------------- #--[Functions]------------------------------------------------------------------ #-------------------------------------------------------------------------------

Functions

#-------------------------------------------------------------------------------

one

Retrieves a constant vector with (1, 1) components.

method one (--> CArray[N-Vec2] )

Return value; the one vector.

#-------------------------------------------------------------------------------

x-axis

Retrieves a constant vector with (1, 0) components.

method x-axis (--> CArray[N-Vec2] )

Return value; the X axis vector.

#-------------------------------------------------------------------------------

y-axis

Retrieves a constant vector with (0, 1) components.

method y-axis (--> CArray[N-Vec2] )

Return value; the Y axis vector.

#-------------------------------------------------------------------------------

zero

Retrieves a constant vector with (0, 0) components.

method zero (--> CArray[N-Vec2] )

Return value; the zero vector.

Gnome::Graphene v0.1.11

Graphene is a library of data types commonly used to implement 2D-in-3D or full 3D canvases

Authors

  • Marcel Timmerman

License

Artistic-2.0

Dependencies

Gnome::GObject:api<2>Gnome::Glib:api<2>Gnome::N:api<2>

Test Dependencies

Provides

  • Gnome::Graphene::N-Box
  • Gnome::Graphene::N-Euler
  • Gnome::Graphene::N-Frustum
  • Gnome::Graphene::N-Matrix
  • Gnome::Graphene::N-Plane
  • Gnome::Graphene::N-Point
  • Gnome::Graphene::N-Point3D
  • Gnome::Graphene::N-Quad
  • Gnome::Graphene::N-Quaternion
  • Gnome::Graphene::N-Ray
  • Gnome::Graphene::N-Rect
  • Gnome::Graphene::N-Size
  • Gnome::Graphene::N-Sphere
  • Gnome::Graphene::N-Triangle
  • Gnome::Graphene::N-Vec2
  • Gnome::Graphene::N-Vec3
  • Gnome::Graphene::N-Vec4
  • Gnome::Graphene::T-box
  • Gnome::Graphene::T-config
  • Gnome::Graphene::T-euler
  • Gnome::Graphene::T-frustum
  • Gnome::Graphene::T-matrix
  • Gnome::Graphene::T-plane
  • Gnome::Graphene::T-point
  • Gnome::Graphene::T-point3d
  • Gnome::Graphene::T-quad
  • Gnome::Graphene::T-quaternion
  • Gnome::Graphene::T-ray
  • Gnome::Graphene::T-rect
  • Gnome::Graphene::T-size
  • Gnome::Graphene::T-sphere
  • Gnome::Graphene::T-triangle
  • Gnome::Graphene::T-vec

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.