N-Vec4

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

Gnome::Graphene::N-Vec4

Description

A structure capable of holding a vector with four dimensions: x, y, z, and w.

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

#------------------------------------------------------------------------------- #--[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_vec4_t structure.

The contents of the returned structure are undefined.

Use .init() to initialize the vector.

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

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

Methods

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

add

Adds each component of the two given vectors.

method add ( CArray[N-Vec4] $b, CArray[N-Vec4] $res )
  • $b; a graphene_vec4_t.

  • $res; return location for the resulting vector.

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

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-Vec4] $b, CArray[N-Vec4] $res )
  • $b; a graphene_vec4_t.

  • $res; return location for the resulting vector.

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

dot

Computes the dot product of the two given vectors.

method dot ( CArray[N-Vec4] $b --> Num )
  • $b; a graphene_vec4_t.

Return value; the value of the dot product.

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

equal This function is not yet available

Checks whether the two given graphene_vec4_t are equal.

method equal ( CArray[N-Vec4] $v2 )
  • $v2; a graphene_vec4_t.

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

free

Frees the resources allocated by $v

method free ( )

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

get-w

Retrieves the value of the fourth component of the given graphene_vec4_t.

method get-w (--> Num )

Return value; the value of the fourth component.

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

get-x

Retrieves the value of the first component of the given graphene_vec4_t.

method get-x (--> Num )

Return value; the value of the first component.

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

get-xy

Creates a graphene_vec2_t that contains the first two components of the given graphene_vec4_t.

method get-xy ( CArray[N-Vec2] $res )
  • $res; return location for a graphene_vec2_t.

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

get-xyz

Creates a graphene_vec3_t that contains the first three components of the given graphene_vec4_t.

method get-xyz ( CArray[N-Vec3] $res )
  • $res; return location for a graphene_vec3_t.

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

get-y

Retrieves the value of the second component of the given graphene_vec4_t.

method get-y (--> Num )

Return value; the value of the second component.

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

get-z

Retrieves the value of the third component of the given graphene_vec4_t.

method get-z (--> Num )

Return value; the value of the third component.

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

init

Initializes a graphene_vec4_t using the given values.

This function can be called multiple times.

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

  • $y; the Y field of the vector.

  • $z; the Z field of the vector.

  • $w; the W field of the vector.

Return value; a pointer to the initialized vector.

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

init-from-float

Initializes a graphene_vec4_t with the values inside the given array.

method init-from-float ( Num() $src --> CArray[N-Vec4] )
  • $src; an array of four floating point values.

Return value; the initialized vector.

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

init-from-vec2

Initializes a graphene_vec4_t using the components of a graphene_vec2_t and the values of $z and $w.

method init-from-vec2 ( CArray[N-Vec2] $src, Num() $z, Num() $w --> CArray[N-Vec4] )
  • $src; a graphene_vec2_t.

  • $z; the value for the third component of $v.

  • $w; the value for the fourth component of $v.

Return value; the initialized vector.

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

init-from-vec3

Initializes a graphene_vec4_t using the components of a graphene_vec3_t and the value of $w.

method init-from-vec3 ( CArray[N-Vec3] $src, Num() $w --> CArray[N-Vec4] )
  • $src; a graphene_vec3_t.

  • $w; the value for the fourth component of $v.

Return value; the initialized vector.

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

init-from-vec4

Initializes a graphene_vec4_t using the components of another graphene_vec4_t.

method init-from-vec4 ( CArray[N-Vec4] $src --> CArray[N-Vec4] )
  • $src; a graphene_vec4_t.

Return value; the initialized vector.

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

interpolate

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

method interpolate ( CArray[N-Vec4] $v2, Num() $factor, CArray[N-Vec4] $res )
  • $v2; a graphene_vec4_t.

  • $factor; the interpolation factor.

  • $res; the interpolated vector.

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

length

Computes the length of the given graphene_vec4_t.

method length (--> Num )

Return value; the length of the vector.

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

max

Compares each component of the two given vectors and creates a vector that contains the maximum values.

method max ( CArray[N-Vec4] $b, CArray[N-Vec4] $res )
  • $b; a graphene_vec4_t.

  • $res; return location for the result vector.

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

min

Compares each component of the two given vectors and creates a vector that contains the minimum values.

method min ( CArray[N-Vec4] $b, CArray[N-Vec4] $res )
  • $b; a graphene_vec4_t.

  • $res; return location for the result vector.

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

multiply

Multiplies each component of the two given vectors.

method multiply ( CArray[N-Vec4] $b, CArray[N-Vec4] $res )
  • $b; a graphene_vec4_t.

  • $res; return location for the resulting vector.

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

near This function is not yet available

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

method near ( CArray[N-Vec4] $v2, Num() $epsilon )
  • $v2; a graphene_vec4_t.

  • $epsilon; the threshold between the two vectors.

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

negate

Negates the given graphene_vec4_t.

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

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

normalize

Normalizes the given graphene_vec4_t.

method normalize ( CArray[N-Vec4] $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-Vec4] $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-Vec4] $b, CArray[N-Vec4] $res )
  • $b; a graphene_vec4_t.

  • $res; return location for the resulting vector.

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

to-float

Stores the components of the given graphene_vec4_t into an array of floating point values.

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

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

Functions

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

one

Retrieves a pointer to a graphene_vec4_t with all its components set to 1.

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

Return value; a constant vector.

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

w-axis

Retrieves a pointer to a graphene_vec4_t with its components set to (0, 0, 0, 1).

method w-axis (--> CArray[N-Vec4] )

Return value; a constant vector.

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

x-axis

Retrieves a pointer to a graphene_vec4_t with its components set to (1, 0, 0, 0).

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

Return value; a constant vector.

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

y-axis

Retrieves a pointer to a graphene_vec4_t with its components set to (0, 1, 0, 0).

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

Return value; a constant vector.

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

z-axis

Retrieves a pointer to a graphene_vec4_t with its components set to (0, 0, 1, 0).

method z-axis (--> CArray[N-Vec4] )

Return value; a constant vector.

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

zero

Retrieves a pointer to a graphene_vec4_t with all its components set to 0.

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

Return value; a constant 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.