Transform¶
This page contains classes defined in hakowan.transform module.
Transform
dataclass
¶
Transform is the base class of all transforms.
Source code in hakowan/grammar/transform/transform.py
__imul__(other)
¶
In place update by applying another transform after the current transform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Transform
|
The transform to apply after the current transform. |
required |
Source code in hakowan/grammar/transform/transform.py
__mul__(other)
¶
Apply another transform, other, after the current transform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Transform
|
The other transform. |
required |
Returns: A new transform that is the composition of the current transform and other.
Source code in hakowan/grammar/transform/transform.py
Filter
dataclass
¶
Bases: Transform
Filter data based on a condition.
Attributes:
| Name | Type | Description |
|---|---|---|
data |
AttributeLike | None
|
The attribute to filter on. If None, the vertex position is used. |
condition |
Callable
|
A callable that takes a single argument, the value of the attribute, and returns a boolean indicating whether the data should be kept. |
Source code in hakowan/grammar/transform/transform.py
UVMesh
dataclass
¶
Bases: Transform
Extract UV mesh from data.
Attributes:
| Name | Type | Description |
|---|---|---|
uv |
AttributeLike | None
|
The attribute defining the UV coordinates. If None, automatically deetect the UV attribute from the data. |
Source code in hakowan/grammar/transform/transform.py
Affine
dataclass
¶
Bases: Transform
Apply affine transformation to data.
Attributes:
| Name | Type | Description |
|---|---|---|
matrix |
ArrayLike
|
The 4x4 affine matrix to apply. |
Source code in hakowan/grammar/transform/transform.py
PrincipalAxes
dataclass
¶
Bases: Transform
Align PCA principal directions of vertex positions with a target orthonormal frame.
Covariance is computed from the current data-frame vertex positions. Principal
axes are ordered by descending eigenvalue (largest variance first). The rotation and
translation match those directions to the columns of frame: column 0 is the
direction for the largest-variance axis, column 1 for the second, column 2 for the third.
The resulting affine is pre-composed with any prior global transform on the layer, so
earlier Affine transforms (translate / rotate / scale) are preserved and applied
before this PCA-based alignment.
Attributes:
| Name | Type | Description |
|---|---|---|
frame |
ArrayLike
|
3x3 matrix whose columns are the target orthonormal axes (see above). |
orthonormalize_frame |
bool
|
If True (default), orthonormalize |
Source code in hakowan/grammar/transform/transform.py
Compute
dataclass
¶
Bases: Transform
Compute new attributes from the current data frame.
Attributes:
| Name | Type | Description |
|---|---|---|
x |
str | None
|
Extract the x coordinate as an attribute. |
y |
str | None
|
Extract the y coordinate as an attribute. |
z |
str | None
|
Extract the z coordinate as an attribute. |
normal |
str | None
|
Compute the normal vector field as an attribute. |
vertex_normal |
str | None
|
Compute the vertex normal vector field as an attribute. |
facet_normal |
str | None
|
Compute the facet normal vector field as an attribute. |
component |
str | None
|
Compute connected component ids. |
Source code in hakowan/grammar/transform/transform.py
Explode
dataclass
¶
Bases: Transform
Explode data into multiple pieces.
Attributes:
| Name | Type | Description |
|---|---|---|
pieces |
AttributeLike
|
The attribute defining the pieces. |
magnitude |
float
|
The magnitude of the displacement. |
Source code in hakowan/grammar/transform/transform.py
Norm
dataclass
¶
Bases: Transform
Compute the row-wise norm of a given vector attribute.
Attributes:
| Name | Type | Description |
|---|---|---|
data |
AttributeLike
|
The vector attribute to compute the norm on. |
norm_attr_name |
str
|
The name of the output norm attribute. |
order |
int
|
The order of the norm. Default is 2, which is the L2 norm. |
Source code in hakowan/grammar/transform/transform.py
Boundary
dataclass
¶
Bases: Transform
Compute the boundary of a mesh.
Attributes:
| Name | Type | Description |
|---|---|---|
attributes |
list[str]
|
The attributes to take into account when computing the boundary. i.e. discontinuities in these attributes will be considered as boundaries. |
Source code in hakowan/grammar/transform/transform.py
Streamline
dataclass
¶
Bases: Transform
Replace the mesh with surface streamlines traced from a per-facet vector or cross field.
The output is a vertex-only mesh whose 2-vertex polygonal faces encode line
segments along the streamlines, suitable for the curve mark. A per-vertex
int32 attribute named by id_attr_name identifies which streamline
each point belongs to.
Attributes:
| Name | Type | Description |
|---|---|---|
vec_field |
AttributeLike
|
The per-facet vector field attribute name. Vertex- or corner- domain attributes are averaged to per-facet first. |
n |
int
|
Number of blue-noise seed faces to sample. Default 50. |
cross_field |
bool
|
Treat the field as 4-RoSy cross field. Default True. |
length |
float | None
|
Maximum object-space length per half-trace (measured on the
data-frame mesh, before any layer-level affine transforms). Tracing
stops once the accumulated length exceeds this value. |
seed |
int
|
RNG seed passed to blue-noise sampling. Default 0. |
min_length |
int
|
Discard streamlines shorter than this many sample points. Default 3. |
id_attr_name |
str
|
Name of the per-vertex streamline-id attribute on the
output mesh. Default |