Triangle
Added in version 1.2.
- class Triangle(*args, **kwargs)
A triangle.
Constructors
Methods
- class Triangle
- contains_point(p: Point3D) bool
Checks whether the given triangle
t
contains the pointp
.Added in version 1.2.
- Parameters:
p – a
Point3D
- equal(b: Triangle) bool
Checks whether the two given
Triangle
are equal.Added in version 1.2.
- Parameters:
b – a
Triangle
- get_barycoords(p: Point3D | None = None) tuple[bool, Vec2]
Computes the barycentric coordinates of the given point
p
.The point
p
must lie on the same plane as the trianglet
; 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
Vec2
contains the following values, in order:res.x = u
res.y = v
Added in version 1.2.
- Parameters:
p – a
Point3D
- get_midpoint() Point3D
Computes the coordinates of the midpoint of the given
Triangle
.The midpoint G is the centroid of the triangle, i.e. the intersection of its medians.
Added in version 1.2.
- get_plane() Plane
Computes the plane based on the vertices of the given
Triangle
.Added in version 1.2.
- get_points() tuple[Point3D, Point3D, Point3D]
Retrieves the three vertices of the given
Triangle
and returns their coordinates asPoint3D
.Added in version 1.2.
- get_uv(p: Point3D | None, uv_a: Vec2, uv_b: Vec2, uv_c: Vec2) tuple[bool, Vec2]
Computes the UV coordinates of the given point
p
.The point
p
must lie on the same plane as the trianglet
; if the point is not coplanar, the result of this function is undefined. Ifp
isNone
, 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()
Added in version 1.10.
- Parameters:
p – a
Point3D
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
- get_vertices() tuple[Vec3, Vec3, Vec3]
Retrieves the three vertices of the given
Triangle
.Added in version 1.2.
- init_from_float(a: Sequence[float], b: Sequence[float], c: Sequence[float]) Triangle
Initializes a
Triangle
using the three given arrays of floating point values, each representing the coordinates of a point in 3D space.Added in version 1.10.
- Parameters:
a – an array of 3 floating point values
b – an array of 3 floating point values
c – an array of 3 floating point values