N-Quaternion

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

Gnome::Graphene::N-Quaternion

Description

A quaternion.

The contents of the Gnome::Graphene::N-Quaternion 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 Gnome::Graphene::N-Quaternion.

The contents of the returned value are undefined.

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

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

Methods

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

add

Adds two Gnome::Graphene::N-Quaternion $a and $b.

method add ( N-Object $b, N-Object $res )
  • $b; a Gnome::Graphene::N-Quaternion

  • $res; the result of the operation

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

dot

Computes the dot product of two Gnome::Graphene::N-Quaternion.

method dot ( N-Object $b --> Num )
  • $b; a Gnome::Graphene::N-Quaternion

Return value; the value of the dot products.

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

equal

Checks whether the given quaternions are equal.

method equal ( N-Object $b --> gboolean )
  • $b; a Gnome::Graphene::N-Quaternion

Return value; true if the quaternions are equal.

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

free

Releases the resources allocated by .alloc().

method free ( )

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

init

Initializes a Gnome::Graphene::N-Quaternion using the given four values.

method init ( Num() $x, Num() $y, Num() $z, Num() $w --> N-Object )
  • $x; the first component of the quaternion.

  • $y; the second component of the quaternion.

  • $z; the third component of the quaternion.

  • $w; the fourth component of the quaternion.

Return value; the initialized quaternion.

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

init-from-angle-vec3

Initializes a Gnome::Graphene::N-Quaternion using an $angle on a specific $axis.

method init-from-angle-vec3 ( Num() $angle, N-Object $axis --> N-Object )
  • $angle; the rotation on a given axis, in degrees.

  • $axis; the axis of rotation, expressed as a vector

Return value; the initialized quaternion.

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

init-from-angles

Initializes a Gnome::Graphene::N-Quaternion using the values of the [Euler angles](http://en.wikipedia.org/wiki/Euler_angles) on each axis.

See also: .init-from-euler()

method init-from-angles ( Num() $deg-x, Num() $deg-y, Num() $deg-z --> N-Object )
  • $deg-x; rotation angle on the X axis (yaw), in degrees.

  • $deg-y; rotation angle on the Y axis (pitch), in degrees.

  • $deg-z; rotation angle on the Z axis (roll), in degrees.

Return value; the initialized quaternion.

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

init-from-euler

Initializes a Gnome::Graphene::N-Quaternion using the given Gnome::Graphene::N-Euler.

method init-from-euler ( N-Object $e --> N-Object )
  • $e; a Gnome::Graphene::N-Euler

Return value; the initialized Gnome::Graphene::N-Quaternion.

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

init-from-matrix

Initializes a Gnome::Graphene::N-Quaternion using the rotation components of a transformation matrix.

method init-from-matrix ( N-Object $m --> N-Object )
  • $m; a Gnome::Graphene::N-Matrix

Return value; the initialized quaternion.

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

init-from-quaternion

Initializes a Gnome::Graphene::N-Quaternion with the values from $src.

method init-from-quaternion ( N-Object $src --> N-Object )
  • $src; a Gnome::Graphene::N-Quaternion

Return value; the initialized quaternion.

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

init-from-radians

Initializes a Gnome::Graphene::N-Quaternion using the values of the [Euler angles](http://en.wikipedia.org/wiki/Euler_angles) on each axis.

See also: .init-from-euler()

method init-from-radians ( Num() $rad-x, Num() $rad-y, Num() $rad-z --> N-Object )
  • $rad-x; rotation angle on the X axis (yaw), in radians.

  • $rad-y; rotation angle on the Y axis (pitch), in radians.

  • $rad-z; rotation angle on the Z axis (roll), in radians.

Return value; the initialized quaternion.

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

init-from-vec4

Initializes a Gnome::Graphene::N-Quaternion with the values from $src.

method init-from-vec4 ( N-Object $src --> N-Object )
  • $src; a graphene_vec4_t

Return value; the initialized quaternion.

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

init-identity

Initializes a Gnome::Graphene::N-Quaternion using the identity transformation.

method init-identity (--> N-Object )

Return value; the initialized quaternion.

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

invert

Inverts a Gnome::Graphene::N-Quaternion, and returns the conjugate quaternion of $q.

method invert ( N-Object $res )
  • $res; return location for the inverted quaternion

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

multiply

Multiplies two Gnome::Graphene::N-Quaternion $a and $b.

method multiply ( N-Object $b, N-Object $res )
  • $b; a Gnome::Graphene::N-Quaternion

  • $res; the result of the operation

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

normalize

Normalizes a Gnome::Graphene::N-Quaternion.

method normalize ( N-Object $res )
  • $res; return location for the normalized quaternion

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

scale

Scales all the elements of a Gnome::Graphene::N-Quaternion $q using the given scalar factor.

method scale ( Num() $factor, N-Object $res )
  • $factor; a scaling factor.

  • $res; the result of the operation

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

slerp

Interpolates between the two given quaternions using a spherical linear interpolation, or [SLERP](http://en.wikipedia.org/wiki/Slerp), using the given interpolation $factor.

method slerp ( N-Object $b, Num() $factor, N-Object $res )
  • $b; a Gnome::Graphene::N-Quaternion

  • $factor; the linear interpolation factor.

  • $res; return location for the interpolated quaternion

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

to-angle-vec3

Converts a quaternion into an $angle, $axis pair.

method to-angle-vec3 ( Num() $angle, N-Object $axis )
  • $angle; (transfer ownership: full) return location for the angle, in degrees.

  • $axis; return location for the rotation axis

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

to-angles

Converts a Gnome::Graphene::N-Quaternion to its corresponding rotations on the [Euler angles](http://en.wikipedia.org/wiki/Euler_angles) on each axis.

method to-angles ( Num() $deg-x, Num() $deg-y, Num() $deg-z )
  • $deg-x; (transfer ownership: full) return location for the rotation angle on the X axis (yaw), in degrees.

  • $deg-y; (transfer ownership: full) return location for the rotation angle on the Y axis (pitch), in degrees.

  • $deg-z; (transfer ownership: full) return location for the rotation angle on the Z axis (roll), in degrees.

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

to-matrix

Converts a quaternion into a transformation matrix expressing the rotation defined by the Gnome::Graphene::N-Quaternion.

method to-matrix ( N-Object $m )
  • $m; a Gnome::Graphene::N-Matrix

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

to-radians

Converts a Gnome::Graphene::N-Quaternion to its corresponding rotations on the [Euler angles](http://en.wikipedia.org/wiki/Euler_angles) on each axis.

method to-radians ( Num() $rad-x, Num() $rad-y, Num() $rad-z )
  • $rad-x; (transfer ownership: full) return location for the rotation angle on the X axis (yaw), in radians.

  • $rad-y; (transfer ownership: full) return location for the rotation angle on the Y axis (pitch), in radians.

  • $rad-z; (transfer ownership: full) return location for the rotation angle on the Z axis (roll), in radians.

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

to-vec4

Copies the components of a Gnome::Graphene::N-Quaternion into a graphene_vec4_t.

method to-vec4 ( N-Object $res )
  • $res; return location for a graphene_vec4_t

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.