Geometry Utilities (mathutils.geometry)

The Blender geometry module

mathutils.geometry.area_tri(v1, v2, v3)

Returns the area size of the 2D or 3D triangle defined.

Parameters:
Return type:

float

mathutils.geometry.barycentric_transform(point, tri_a1, tri_a2, tri_a3, tri_b1, tri_b2, tri_b3)

Return a transformed point, the transformation is defined by 2 triangles.

Parameters:
  • point (mathutils.Vector) – The point to transform.
  • tri_a1 (mathutils.Vector) – source triangle vertex.
  • tri_a2 (mathutils.Vector) – source triangle vertex.
  • tri_a3 (mathutils.Vector) – source triangle vertex.
  • tri_a1 – target triangle vertex.
  • tri_a2 – target triangle vertex.
  • tri_a3 – target triangle vertex.
Returns:

The transformed point

Return type:

mathutils.Vector‘s

mathutils.geometry.box_pack_2d(boxes)

Returns the normal of the 3D tri or quad.

Parameters:boxes (list) – list of boxes, each box is a list where the first 4 items are [x, y, width, height, ...] other items are ignored.
Returns:the width and height of the packed bounding box
Return type:tuple, pair of floats
mathutils.geometry.interpolate_bezier(knot1, handle1, handle2, knot2, resolution)

Interpolate a bezier spline segment.

Parameters:
Returns:

The interpolated points

Return type:

list of mathutils.Vector‘s

mathutils.geometry.intersect_line_line(v1, v2, v3, v4)

Returns a tuple with the points on each line respectively closest to the other.

Parameters:
Return type:

tuple of mathutils.Vector‘s

mathutils.geometry.intersect_line_line_2d(lineA_p1, lineA_p2, lineB_p1, lineB_p2)

Takes 2 lines (as 4 vectors) and returns a vector for their point of intersection or None.

Parameters:
Returns:

The point of intersection or None when not found

Return type:

mathutils.Vector or None

mathutils.geometry.intersect_line_plane(line_a, line_b, plane_co, plane_no, no_flip=False)

Takes 2 lines (as 4 vectors) and returns a vector for their point of intersection or None.

Parameters:
  • line_a (mathutils.Vector) – First point of the first line
  • line_b (mathutils.Vector) – Second point of the first line
  • plane_co (mathutils.Vector) – A point on the plane
  • plane_no (mathutils.Vector) – The direction the plane is facing
  • no_flip (:boolean) – Always return an intersection on the directon defined bt line_a -> line_b
Returns:

The point of intersection or None when not found

Return type:

mathutils.Vector or None

mathutils.geometry.intersect_point_line(pt, line_p1, line_p2)

Takes a point and a line and returns a tuple with the closest point on the line and its distance from the first point of the line as a percentage of the length of the line.

Parameters:
Return type:

(mathutils.Vector, float)

mathutils.geometry.intersect_point_quad_2d(pt, quad_p1, quad_p2, quad_p3, quad_p4)

Takes 5 vectors (using only the x and y coordinates): one is the point and the next 4 define the quad, only the x and y are used from the vectors. Returns 1 if the point is within the quad, otherwise 0.

Parameters:
Return type:

int

mathutils.geometry.intersect_point_tri_2d(pt, tri_p1, tri_p2, tri_p3)

Takes 4 vectors (using only the x and y coordinates): one is the point and the next 3 define the triangle. Returns 1 if the point is within the triangle, otherwise 0.

Parameters:
Return type:

int

mathutils.geometry.intersect_ray_tri(v1, v2, v3, ray, orig, clip=True)

Returns the intersection between a ray and a triangle, if possible, returns None otherwise.

Parameters:
Returns:

The point of intersection or None if no intersection is found

Return type:

mathutils.Vector or None

mathutils.geometry.normal(v1, v2, v3, v4=None)

Returns the normal of the 3D tri or quad.

Parameters:
Return type:

mathutils.Vector

mathutils.geometry.tesselate_polygon(veclist_list)

Takes a list of polylines (each point a vector) and returns the point indices for a polyline filled with triangles.

Parameters:veclist_list – list of polylines
Return type:list

Previous topic

Math Types & Utilities (mathutils)

Next topic

Font Drawing (blf)