Graphene.Triangle¶
Fields¶
Name |
Type |
Access |
Description |
---|---|---|---|
a |
r |
||
b |
r |
||
c |
r |
Methods¶
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- class Graphene.Triangle¶
A triangle.
New in version 1.2.
- classmethod alloc()¶
- Returns:
the newly allocated
Graphene.Triangle
structure. UseGraphene.Triangle.free
() to free the resources allocated by this function- Return type:
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
) – aGraphene.Point3D
- Returns:
true
if the point is inside the triangle- Return type:
Checks whether the given triangle self contains the point p.
New in version 1.2.
- equal(b)¶
- Parameters:
b (
Graphene.Triangle
) – aGraphene.Triangle
- Returns:
true
if the triangles are equal- Return type:
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:
Computes the area of the given
Graphene.Triangle
.New in version 1.2.
- get_barycoords(p)¶
- Parameters:
p (
Graphene.Point3D
orNone
) – aGraphene.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; andv
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 asGraphene.Point3D
.New in version 1.2.
- get_uv(p, uv_a, uv_b, uv_c)¶
- Parameters:
p (
Graphene.Point3D
orNone
) – aGraphene.Point3D
uv_a (
Graphene.Vec2
) – the UV coordinates of the first pointuv_b (
Graphene.Vec2
) – the UV coordinates of the second pointuv_c (
Graphene.Vec2
) – the UV coordinates of the third point
- 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:
- Returns:
the initialized
Graphene.Triangle
- Return type:
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:
a (
Graphene.Point3D
orNone
) – aGraphene.Point3D
b (
Graphene.Point3D
orNone
) – aGraphene.Point3D
c (
Graphene.Point3D
orNone
) – aGraphene.Point3D
- Returns:
the initialized
Graphene.Triangle
- Return type:
Initializes a
Graphene.Triangle
using the three given 3D points.New in version 1.2.
- init_from_vec3(a, b, c)¶
- Parameters:
a (
Graphene.Vec3
orNone
) – aGraphene.Vec3
b (
Graphene.Vec3
orNone
) – aGraphene.Vec3
c (
Graphene.Vec3
orNone
) – aGraphene.Vec3
- Returns:
the initialized
Graphene.Triangle
- Return type:
Initializes a
Graphene.Triangle
using the three given vectors.New in version 1.2.