
NO_TITLE
Gnome::Graphene::N-Triangle
Description
A triangle.
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-Triangle.
The contents of the returned structure are undefined.
method alloc ( --> Gnome::Graphene::Triangle \)
Methods
contains-point
Checks whether the given triangle $t
contains the point $p
.
method contains-point ( N-Object $p --> gboolean )
$p; a graphene_point3d_t
Return value; true if the point is inside the triangle.
equal
Checks whether the two given Gnome::Graphene::N-Triangle are equal.
method equal ( N-Object $b --> gboolean )
$b; a Gnome::Graphene::N-Triangle
Return value; true if the triangles are equal.
free
Frees the resources allocated by .alloc()
.
method free ( )
get-area
Computes the area of the given Gnome::Graphene::N-Triangle.
method get-area (--> Num )
Return value; the area of the triangle.
get-barycoords
Computes the [barycentric coordinates](http://en.wikipedia.org/wiki/Barycentric_coordinate_system) of the given point $p
.
The point $p
must lie on the same plane as the triangle $t
; if the point is not coplanar, the result of this function is undefined.
If we place the origin in the coordinates of the triangle's A point, the barycentric coordinates are u, which is on the AC vector; and v which is on the AB vector:

The returned graphene_vec2_t contains the following values, in order:
res.x = u
res.y = v
method get-barycoords ( N-Object $p, N-Object $res --> gboolean )
$p; a graphene_point3d_t
$res; return location for the vector with the barycentric coordinates
Return value; true if the barycentric coordinates are valid.
get-bounding-box
Computes the bounding box of the given Gnome::Graphene::N-Triangle.
method get-bounding-box ( N-Object $res )
$res; return location for the box
get-midpoint
Computes the coordinates of the midpoint of the given Gnome::Graphene::N-Triangle.
The midpoint G is the [centroid](https://en.wikipedia.org/wiki/Centroid#Triangle_centroid) of the triangle, i.e. the intersection of its medians.
method get-midpoint ( N-Object $res )
$res; return location for the coordinates of the midpoint
get-normal
Computes the normal vector of the given Gnome::Graphene::N-Triangle.
method get-normal ( N-Object $res )
$res; return location for the normal vector
get-plane
Computes the plane based on the vertices of the given Gnome::Graphene::N-Triangle.
method get-plane ( N-Object $res )
$res; return location for the plane
get-points
Retrieves the three vertices of the given Gnome::Graphene::N-Triangle and returns their coordinates as graphene_point3d_t.
method get-points ( N-Object $a, N-Object $b, N-Object $c )
$a; return location for the coordinates of the first vertex
$b; return location for the coordinates of the second vertex
$c; return location for the coordinates of the third vertex
get-uv
Computes the UV coordinates of the given point $p
.
The point $p
must lie on the same plane as the triangle $t
; if the point is not coplanar, the result of this function is undefined. If $p
is undefined, the point will be set in (0, 0, 0).
The UV coordinates will be placed in the $res
vector:
res.x = u
res.y = v
See also: .get-barycoords()
method get-uv ( N-Object $p, N-Object $uv-a, N-Object $uv-b, N-Object $uv-c, N-Object $res --> gboolean )
$p; a graphene_point3d_t
$uv-a; the UV coordinates of the first point
$uv-b; the UV coordinates of the second point
$uv-c; the UV coordinates of the third point
$res; a vector containing the UV coordinates of the given point
$p
Return value; true if the coordinates are valid.
get-vertices
Retrieves the three vertices of the given Gnome::Graphene::N-Triangle.
method get-vertices ( N-Object $a, N-Object $b, N-Object $c )
$a; return location for the first vertex
$b; return location for the second vertex
$c; return location for the third vertex
init-from-float
Initializes a Gnome::Graphene::N-Triangle using the three given arrays of floating point values, each representing the coordinates of a point in 3D space.
method init-from-float ( Num() $a, Num() $b, Num() $c --> N-Object )
$a; an array of 3 floating point values.
$b; an array of 3 floating point values.
$c; an array of 3 floating point values.
Return value; the initialized Gnome::Graphene::N-Triangle.
init-from-point3d
Initializes a Gnome::Graphene::N-Triangle using the three given 3D points.
method init-from-point3d ( N-Object $a, N-Object $b, N-Object $c --> N-Object )
$a; a graphene_point3d_t
$b; a graphene_point3d_t
$c; a graphene_point3d_t
Return value; the initialized Gnome::Graphene::N-Triangle.
init-from-vec3
Initializes a Gnome::Graphene::N-Triangle using the three given vectors.
method init-from-vec3 ( N-Object $a, N-Object $b, N-Object $c --> N-Object )
$a; a graphene_vec3_t
$b; a graphene_vec3_t
$c; a graphene_vec3_t
Return value; the initialized Gnome::Graphene::N-Triangle.