trimesh.path.simplify module¶
- trimesh.path.simplify.fit_circle_check(points, scale, prior=None, final=False, verbose=False)¶
Fit a circle, and reject the fit if: * the radius is larger than tol.radius_min*scale or tol.radius_max*scale * any segment spans more than tol.seg_angle * any segment is longer than tol.seg_frac*scale * the fit deviates by more than tol.radius_frac*radius * the segments on the ends deviate from tangent by more than tol.tangent
- Parameters:
points ((n, d)) – List of points which represent a path
prior ((center, radius) tuple) – Best guess or None if unknown
scale (float) – What is the overall scale of the set of points
verbose (bool) – Output log.debug messages for the reasons for fit rejection only suggested for manual debugging
- Returns:
if fit is acceptable – (center, radius) tuple
else – None
- trimesh.path.simplify.is_circle(points, scale, verbose=False)¶
Given a set of points, quickly determine if they represent a circle or not.
- Parameters:
points ((n,2 ) float) – Points in space
scale (float) – Scale of overall drawing
verbose (bool) – Print all fit messages or not
- Returns:
control – None, if not a circle
- Return type:
(3,2) float, points in space, OR
- trimesh.path.simplify.merge_colinear(points, scale)¶
Given a set of points representing a path in space, merge points which are colinear.
- Parameters:
points ((n, dimension) float) – Points in space
scale (float) – Scale of drawing for precision
- Returns:
merged – Points with colinear and duplicate points merged, where (j < n)
- Return type:
(j, d) float
- trimesh.path.simplify.points_to_spline_entity(points, smooth=None, count=None)¶
Create a spline entity from a curve in space
- Parameters:
points ((n, dimension) float) – Points in space
smooth (float) – Smoothing distance
count (int or None) – Number of samples desired in result
- Returns:
entity (entities.BSpline) – Entity object with points indexed at zero
control ((m, dimension) float) – New vertices for entity
- trimesh.path.simplify.resample_spline(points, smooth=0.001, count=None, degree=3)¶
Resample a path in space, smoothing along a b-spline.
- Parameters:
points ((n, dimension) float) – Points in space
smooth (float) – Smoothing distance
count (int or None) – Number of samples desired in output
degree (int) – Degree of spline polynomial
- Returns:
resampled – Points in space
- Return type:
(count, dimension) float
- trimesh.path.simplify.simplify_basic(drawing, process=False, **kwargs)¶
Merge colinear segments and fit circles.
- trimesh.path.simplify.simplify_spline(path, smooth=None, verbose=False)¶
Replace discrete curves with b-spline or Arc and return the result as a new Path2D object.
- Parameters:
path (trimesh.path.Path2D) – Input geometry
smooth (float) – Distance to smooth
- Returns:
simplified – Consists of Arc and BSpline entities
- Return type: