Graphene.Triangle

Fields

Name

Type

Access

Description

a

Graphene.Vec3

r

b

Graphene.Vec3

r

c

Graphene.Vec3

r

Methods

class

alloc ()

contains_point (p)

equal (b)

free ()

get_area ()

get_barycoords (p)

get_bounding_box ()

get_midpoint ()

get_normal ()

get_plane ()

get_points ()

get_uv (p, uv_a, uv_b, uv_c)

get_vertices ()

init_from_float (a, b, c)

init_from_point3d (a, b, c)

init_from_vec3 (a, b, c)

Details

class Graphene.Triangle

A triangle.

New in version 1.2.

classmethod alloc()
Returns:

the newly allocated Graphene.Triangle structure. Use Graphene.Triangle.free() to free the resources allocated by this function

Return type:

Graphene.Triangle

Allocates a new Graphene.Triangle.

The contents of the returned structure are undefined.

New in version 1.2.

contains_point(p)
Parameters:

p (Graphene.Point3D) – a Graphene.Point3D

Returns:

true if the point is inside the triangle

Return type:

bool

Checks whether the given triangle self contains the point p.

New in version 1.2.

equal(b)
Parameters:

b (Graphene.Triangle) – a Graphene.Triangle

Returns:

true if the triangles are equal

Return type:

bool

Checks whether the two given Graphene.Triangle are equal.

New in version 1.2.

free()

Frees the resources allocated by Graphene.Triangle.alloc().

New in version 1.2.

get_area()
Returns:

the area of the triangle

Return type:

float

Computes the area of the given Graphene.Triangle.

New in version 1.2.

get_barycoords(p)
Parameters:

p (Graphene.Point3D or None) – a Graphene.Point3D

Returns:

true if the barycentric coordinates are valid

res:

return location for the vector with the barycentric coordinates

Return type:

(bool, res: Graphene.Vec2)

Computes the barycentric coordinates of the given point p.

The point p must lie on the same plane as the triangle self; 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 contains the following values, in order:

  • res.x = u

  • res.y = v

New in version 1.2.

get_bounding_box()
Returns:

return location for the box

Return type:

res: Graphene.Box

Computes the bounding box of the given Graphene.Triangle.

New in version 1.2.

get_midpoint()
Returns:

return location for the coordinates of the midpoint

Return type:

res: Graphene.Point3D

Computes the coordinates of the midpoint of the given Graphene.Triangle.

The midpoint G is the centroid of the triangle, i.e. the intersection of its medians.

New in version 1.2.

get_normal()
Returns:

return location for the normal vector

Return type:

res: Graphene.Vec3

Computes the normal vector of the given Graphene.Triangle.

New in version 1.2.

get_plane()
Returns:

return location for the plane

Return type:

res: Graphene.Plane

Computes the plane based on the vertices of the given Graphene.Triangle.

New in version 1.2.

get_points()
Returns:

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

Return type:

(a: Graphene.Point3D, b: Graphene.Point3D, c: Graphene.Point3D)

Retrieves the three vertices of the given Graphene.Triangle and returns their coordinates as Graphene.Point3D.

New in version 1.2.

get_uv(p, uv_a, uv_b, uv_c)
Parameters:
Returns:

true if the coordinates are valid

res:

a vector containing the UV coordinates of the given point p

Return type:

(bool, res: Graphene.Vec2)

Computes the UV coordinates of the given point p.

The point p must lie on the same plane as the triangle self; if the point is not coplanar, the result of this function is undefined. If p is None, 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()

New in version 1.10.

get_vertices()
Returns:

a:

return location for the first vertex

b:

return location for the second vertex

c:

return location for the third vertex

Return type:

(a: Graphene.Vec3, b: Graphene.Vec3, c: Graphene.Vec3)

Retrieves the three vertices of the given Graphene.Triangle.

New in version 1.2.

init_from_float(a, b, c)
Parameters:
  • a ([float]) – an array of 3 floating point values

  • b ([float]) – an array of 3 floating point values

  • c ([float]) – an array of 3 floating point values

Returns:

the initialized Graphene.Triangle

Return type:

Graphene.Triangle

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

New in version 1.10.

init_from_point3d(a, b, c)
Parameters:
Returns:

the initialized Graphene.Triangle

Return type:

Graphene.Triangle

Initializes a Graphene.Triangle using the three given 3D points.

New in version 1.2.

init_from_vec3(a, b, c)
Parameters:
Returns:

the initialized Graphene.Triangle

Return type:

Graphene.Triangle

Initializes a Graphene.Triangle using the three given vectors.

New in version 1.2.