primitives - 3D Primitives for Wire generation

Primitives are parametrized objects, that can be baked into a mesh/web/wire object. A primitive object must have the following signature:

class SomePrimitive:
        # method baking the primitive in some general-purpose 3D object
        # resolution is optional and defaults to the primitive settings that defaults to the current settings at call time
        def mesh(self, resolution=None) -> Mesh/Web/Wire:
                ...

        # for the solver
        # primitive attributes the solver has to consider as variables or variable container
        slvvars = 'fields', 'for', 'solver', 'variables'
        # otpional method constraining the primitive parameters (to keep points on a circle for instance)
        def fit(self) -> err**2 as float:
                ...
isprimitive(obj)

return True if obj match the signature for primitives

Curve resolution

Some primitive types are curves, the discretisation is important for visual as well as for result quality (remember that even if something looks like a perfect curves, it’s still polygons). The resolution (subdivision) of curve is done following the following cirterions present in the settings module

specification priority order:

  1. optional argument resolution passed to primitive.mesh() or to web() or wire()

  2. optional attribute resolution of the primitive object

  3. value of settings.primitives['curve_resolution'] at bake time.

specification format:

('fixed', 16)   # fixed amount of 16 subdivisions
('rad', 0.6)    # max polygon angle is 0.6 rad
('radm', 0.6)
('radm2', 0.6)

primitives types

class Vector

Alias to vec3

class Point

Alias to vec3

class Axis(origin, direction, interval=None)

Mimic the behavior of a tuple, but with the primitive signature.

__getitem__(i)
../_images/primitives-axis.png
isaxis(obj)

return True if the given object is considered to be an axis. An axis can be an instance of Axis or a tuple (vec3, vec3)

class Segment(a, b)

segment from a to b

property direction
../_images/primitives-segment.png
class ArcCentered(axis, a, b, resolution=None)

arc from a to b, centered around the origin of the axis.

An axis is requested instead of a point (that would be more intuitive), to solve the problem when a,b, center are aligned

property center
property radius
tangent(pt)

tangent to the closest point of the curve to pt

../_images/primitives-arccentered.png
class ArcThrough(a, b, c, resolution=None)

arc from a to c, passing through b

property center
property radius
property axis
tangent(pt)

tangent to the closest point of the curve to pt

../_images/primitives-arcthrough.png
class Circle(axis, radius, alignment=dvec3(1, 0, 0), resolution=None)

circle centered around the axis origin, with the given radius, in an orthogonal plane to the axis direction

property center
tangent(pt)

tangent to the closest point of the curve to pt

../_images/primitives-circle.png
class ArcTangent(a, b, c, resolution=None)

An arc always tangent to Segment(a,b) and Segment(c,b). The solution is unique.

property center
property radius
property axis
tangent(pt)

tangent to the closest point of the curve to pt

../_images/primitives-arctangent.png
class TangentEllipsis(a, b, c, resolution=None)

An quater of ellipsis always tangent to Segment(a,b) and Segment(c,b). The solution is unique.

property center
property axis
tangent(pt)

tangent to the closest point of the curve to pt

../_images/primitives-tangentellipsis.png
class Interpolated(points, weights=None, resolution=None)

interpolated curve passing through the given points (3rd degree bezier spline)

the tangent in each point is determined by the direction between adjacent points the point weights is how flattened is the curve close to the point tangents

../_images/primitives-spline-interpolated.png
class Softened(points, weights=None, resolution=None)

interpolated curve tangent to each segment midpoint (3rd degree bezier curve)

the points weights is the weight in the determination of each midpoint

../_images/primitives-spline-softened.png