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'
# optional method constraining the primitive parameters (to keep points on a circle for instance)
def fit(self) -> err**2 as float:
...
Curve resolution
Some primitive types are curves, the discretization 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 criterion present in the settings module
Specification priority order:
- Optional argument
resolution
passed toprimitive.mesh()
or toweb()
orwire()
- Optional attribute
resolution
of the primitive object- 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)[source] Mimic the behavior of a tuple, but with the primitive signature.
-
isaxis
(obj)[source] 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
ArcCentered
(axis, a, b, resolution=None)[source] 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
-
property
-
class
ArcThrough
(a, b, c, resolution=None)[source] Arc from a to c, passing through b
-
property
center
-
property
radius
-
property
axis
-
property
-
class
Circle
(axis, radius, alignment=dvec3(1, 0, 0), resolution=None)[source] Circle centered around the axis origin, with the given radius, in an orthogonal plane to the axis direction
-
property
center
-
property
-
class
ArcTangent
(a, b, c, resolution=None)[source] An arc always tangent to
Segment(a,b)
andSegment(c,b)
. The solution is unique.-
property
center
-
property
radius
-
property
axis
-
property
-
class
TangentEllipsis
(a, b, c, resolution=None)[source] An quater of ellipsis always tangent to
Segment(a,b)
andSegment(c,b)
. The solution is unique.-
property
center
-
property
axis
-
property
-
class
Interpolated
(points, weights=None, resolution=None)[source] 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