package ocgtk

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Wrappers.Triangle

type t = [ `triangle ] Gobject.obj
val alloc : unit -> t

Create a new Triangle

val init_from_vec3 : t -> [ `vec3 ] Gobject.obj option -> [ `vec3 ] Gobject.obj option -> [ `vec3 ] Gobject.obj option -> t

Initializes a #graphene_triangle_t using the three given vectors.

val init_from_point3d : t -> [ `point3_d ] Gobject.obj option -> [ `point3_d ] Gobject.obj option -> [ `point3_d ] Gobject.obj option -> t

Initializes a #graphene_triangle_t using the three given 3D points.

val init_from_float : t -> float array -> float array -> float array -> t

Initializes a #graphene_triangle_t using the three given arrays of floating point values, each representing the coordinates of a point in 3D space.

val get_vertices : t -> [ `vec3 ] Gobject.obj * [ `vec3 ] Gobject.obj * [ `vec3 ] Gobject.obj

Retrieves the three vertices of the given #graphene_triangle_t.

val get_uv : t -> [ `point3_d ] Gobject.obj option -> [ `vec2 ] Gobject.obj -> [ `vec2 ] Gobject.obj -> [ `vec2 ] Gobject.obj -> bool * [ `vec2 ] Gobject.obj

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 %NULL, 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: graphene_triangle_get_barycoords()

val get_points : t -> [ `point3_d ] Gobject.obj * [ `point3_d ] Gobject.obj * [ `point3_d ] Gobject.obj

Retrieves the three vertices of the given #graphene_triangle_t and returns their coordinates as #graphene_point3d_t.

val get_plane : t -> [ `plane ] Gobject.obj

Computes the plane based on the vertices of the given #graphene_triangle_t.

val get_normal : t -> [ `vec3 ] Gobject.obj

Computes the normal vector of the given #graphene_triangle_t.

val get_midpoint : t -> [ `point3_d ] Gobject.obj

Computes the coordinates of the midpoint of the given #graphene_triangle_t.

The midpoint G is the centroid(https://en.wikipedia.org/wiki/Centroid#Triangle_centroid) of the triangle, i.e. the intersection of its medians.

val get_bounding_box : t -> [ `box ] Gobject.obj

Computes the bounding box of the given #graphene_triangle_t.

val get_barycoords : t -> [ `point3_d ] Gobject.obj option -> bool * [ `vec2 ] Gobject.obj

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:

!(triangle-barycentric.png)

The returned #graphene_vec2_t contains the following values, in order:

  • `res.x = u`
  • `res.y = v`
val get_area : t -> float

Computes the area of the given #graphene_triangle_t.

val equal : t -> t -> bool

Checks whether the two given #graphene_triangle_t are equal.

val contains_point : t -> [ `point3_d ] Gobject.obj -> bool

Checks whether the given triangle @t contains the point @p.