Point ¶
Point(a=None, mode='COPY', selector=None, attr_from=None, **attrs)
Point domain for cloud and instances.
Adds optional rotation/scale fields and a convenient kinematics initializer, along with several spatial distribution helpers.
Attributes:
Name | Type | Description |
---|---|---|
position |
(N, 3) float
|
Point positions. |
radius |
(N,) float, optional
|
Point radius (e.g., for particle/cloud visualization). |
model_index |
(N,) int, optional
|
Instance model index. |
euler |
(N, 3) float, optional
|
Euler angles (radians). |
quat |
(N, 4) float, optional
|
Quaternion rotation in (x, y, z, w) convention. |
scale |
(N, 3) float, optional
|
Per-point scale. |
Kinematics (created by init_kinematics()
)
speed, accel, force : (N, 3) float Linear kinematics fields. mass : (N,) float Mass per point. moment : (N,) float Moment of inertia proxy (placeholder). omega, torque : (N, 3) float Angular velocity and torque. age : (N,) float Age (seconds or user-defined units). locked : (N,) bool Lock flag. last_pos : (N, 3) float Previous position. viscosity : (N,) float Drag coefficient.
Properties
has_rotation : bool
True if either euler
or quat
is present.
rotation : Rotation or Quaternion
Combined rotation (quaternion ⊗ euler if both present).
Methods (selection)
init_kinematics() Add standard kinematics fields. line_dist(), arc_dist(), circle_dist(), rect_dist(), pie_dist(), disk_dist(), cylinder_dist(), sphere_dist(), dome_dist(), cube_dist(), ball_dist() Populate positions (and related attributes like tangent/normal) from common geometric distributions. speed_along(), disk_speed(), shake_speed() Generate velocity vectors according to distributions.
Examples:
Create a ring of instances with tangents:
pts = Point().circle_dist(radius=2.0, count=128, seed=0)
# tangents and angles are appended automatically
Compose rotations and apply scale:
R = pts.rotation # auto-composed from euler/quat
pts.apply_scale(0.5)
pts.transform(R) # re-apply or chain with other transforms
Initialize a domain array and its attribute schema.
Initializes the storage from an existing array/domain or creates an empty structure. Optionally merges attribute definitions/values from another domain and keyword-provided attributes.
Domains are never instancied directly but by owning geometries.
Actual Domains are Vertex
, [Faces
][npblender.Faces],
Corner
, Edge
,
ControlPoint
, Spline
and Point
.
Domains are initialized with their defaults attributes, for instance position
for
point domaines.
Use attributes can be freely added.
Note: user attributes are saved in Blender Mesh objects only, Blender Curve objects don't store user attributes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a
|
array - like or FieldArray or None
|
Source data used to initialize the domain. If |
None
|
mode
|
(COPY, CAPTURE, EMPTY)
|
Initialization mode. |
'COPY'
|
selector
|
Any
|
Optional row/element selector applied to |
None
|
attr_from
|
Domain or Mapping or None
|
Attribute schema (and possibly values) to merge into this domain. |
None
|
**attrs
|
Additional attribute name/value pairs to inject or override. |
{}
|
Notes
The effective attribute list results from _declare_attributes()
, then
attr_from
, then **attrs
(later entries take precedence).
Examples:
cube = Mesh.cube() # points, corners, faces and edges domains are created
# Adding named attribute to point domain
cube.points.new_float('age')
# Setting the age
cube.points.age = np.random.uniforme(10, 10, len(cube.points))
actual_names
property
¶
actual_names
Column names.
Returns the actual field names, excluding optional fields.
has_rotation
property
¶
has_rotation
Whether this domain has an orientation field.
Returns:
Type | Description |
---|---|
bool
|
|
See Also
rotation
:
Access the per-point rotation object.
get_rotation
:
Safe accessor that can return a default.
rotation
property
¶
rotation
Per-point rotation object from Euler and/or quaternion.
If both euler
and quat
exist, returns their composition
(quaternion composed with Euler). If neither exists, returns an
identity rotation with shape (len(position),)
.
Returns:
Type | Description |
---|---|
Rotation
|
The point rotation |
See Also
has_rotation
:
Check if a rotation is available.
get_rotation
:
Return a default when no rotation is stored.
Examples:
R = P.rotation # rotation object (vectorized)
eul = R.as_euler() # (N, 3)
quat = R.as_quaternion() # (N, 4) in (x, y, z, w)
transdom_names
property
¶
transdom_names
List the names of trans-domain attributes.
Returns:
Type | Description |
---|---|
list of str
|
Names of attributes flagged with |
Examples:
names = D.transdom_names()
x
property
writable
¶
x
X coordinate accessor.
Shorthand for position[..., 0]
. Reading returns a view; assigning to
this property writes into the underlying position
field.
Returns:
Type | Description |
---|---|
ndarray
|
View of shape |
Examples:
Read and write x in place:
xs = points.x # view on position[..., 0]
points.x = xs + 1.0 # shift x by +1
Note: This is equivalent to
points.position[..., 0]
.
y
property
writable
¶
y
Y coordinate accessor.
Shorthand for position[..., 1]
. Reading returns a view; assigning to
this property writes into the underlying position
field.
Returns:
Type | Description |
---|---|
ndarray
|
View of shape |
Examples:
points.y = 0.0 # flatten all y to 0
z
property
writable
¶
z
Z coordinate accessor.
Shorthand for position[..., 2]
. Reading returns a view; assigning to
this property writes into the underlying position
field.
Returns:
Type | Description |
---|---|
ndarray
|
View of shape |
Examples:
points.z += 2.5
add ¶
add(count, **fields)
Add count records
New records are set with default values or values provided by the user in fields dict.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
Number of records to add. |
required |
fields
|
dict
|
Keyword arguments mapping field names to values. |
{}
|
append ¶
append(**fields)
Append values to the structured array.
The number of records to append is determined by the number of fields provided in the fields dictionary. The values of the fields are copied to the new records.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fields
|
dict
|
Keyword arguments mapping field names to values. |
{}
|
apply_scale ¶
apply_scale(scale, pivot=None)
Apply per-axis scales to positions and multiply the scale
attribute.
Calls the base point scaling
([apply_scale
][npblender.PointDomain.apply_scale]) to update
position
(optionally about pivot
), then multiplies the per-point
scale
attribute when present.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scale
|
array-like of shape ``(..., 3)``
|
Per-axis scale factors broadcastable to the domain size. |
required |
pivot
|
array-like of shape ``(..., 3)`` or None
|
Pivot location(s). If |
None
|
Returns:
Type | Description |
---|---|
Point
|
Self (for chaining). |
Raises:
Type | Description |
---|---|
ValueError
|
If broadcasting cannot align inputs with the domain (raised by
[ |
arc_dist ¶
arc_dist(radius=1.0, scale=None, center=(0, 0, 0), arc_center=0.0, arc_angle=np.pi / 2, use_vonmises=False, count=10, density=None, seed=None)
see distributions in maths.distribs
as_kwargs ¶
as_kwargs(selector=None, include=None, exclude=None)
Return a dictionary of field values formatted as kwargs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
selector
|
slice, int, list, or mask
|
Optional selection of elements to extract. |
None
|
include
|
list[str]
|
List of field names (original or python names) to include. |
None
|
exclude
|
list[str]
|
List of field names (original or python names) to exclude. |
None
|
Returns:
Type | Description |
---|---|
dict
|
Mapping from python-safe field names to array values. |
ball_dist ¶
ball_dist(radius=1.0, axis=(0, 0, 1), angle=np.pi, use_vonmises=False, center=(0, 0, 0), count=10, density=None, scale=None, seed=None, **kwargs)
see distributions in maths.distribs
circle_dist ¶
circle_dist(radius=1.0, scale=None, center=(0, 0, 0), count=10, density=None, seed=None)
see distributions in maths.distribs
copy_field ¶
copy_field(field_name, new_name, **infos)
Duplicate an existing field under a new name, with optional metadata overrides.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field_name
|
str
|
The name of the existing field to copy. |
required |
new_name
|
str
|
The name of the new field to create. |
required |
infos
|
keyword arguments
|
Optional metadata (e.g. default, unit, description...) to override or supplement the original field's metadata. |
{}
|
Raises:
Type | Description |
---|---|
KeyError
|
If the source field does not exist. |
ValueError
|
If the target name already exists or is reserved. |
cube_dist ¶
cube_dist(size=1, center=(0, 0, 0), count=10, density=None, seed=None)
see distributions in maths.distribs
cylinder_dist ¶
cylinder_dist(radius=1.0, scale=None, height=1.0, center=(0, 0, 0), arc_center=0.0, arc_angle=2 * np.pi, use_vonmises=False, count=10, density=None, seed=None)
see distributions in maths.distribs
delete ¶
delete(index)
Delete a selection of items from the array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index
|
int, slice, or array-like
|
The indices of the elements to delete from the current data. |
required |
Notes
This operates only on the valid range [0:self._length]
.
The internal buffer is preserved (no reallocation).
disk_speed ¶
disk_speed(speed=1, max_speed=None, normal=None, seed=None)
Sample velocity vectors in a disk (2D radial distribution).
Samples vectors lying in a plane (given by normal
) with lengths in
[0, max_speed]
(or fixed speed
if max_speed
is None
).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
speed
|
float
|
Base radius or fixed magnitude when |
1
|
max_speed
|
float or None
|
Maximum radius; if provided, lengths are sampled in |
None
|
normal
|
(3,) float or None
|
Plane normal. If |
None
|
seed
|
int or None
|
|
None
|
Returns:
Type | Description |
---|---|
ndarray of shape ``(N, 3)``
|
Sampled velocity vectors. |
Raises:
Type | Description |
---|---|
ValueError
|
If inputs are invalid (propagated from the backend). |
dome_dist ¶
dome_dist(radius=1.0, scale=None, axis=(0, 0, 1), angle=np.pi / 2, use_vonmises=False, center=(0, 0, 0), count=10, density=None, seed=None)
see distributions in maths.distribs
dump ¶
dump(title='Dump', attributes=None, target='SCREEN')
Pretty-print or export domain content.
Formats attribute values and prints to screen or builds a tabular dump suitable for spreadsheets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title
|
str
|
Title displayed in the report. |
'Dump'
|
attributes
|
Sequence[str] or None
|
Subset of attribute names to include. If |
None
|
target
|
(SCREEN, ...)
|
Output target. |
'SCREEN'
|
Returns:
Type | Description |
---|---|
None
|
|
Examples:
Domain(points).dump(title="Vertices")
Note: Formatting adapts to the chosen
target
.
extend ¶
extend(other, join_fields=True)
Append multiple records from another array or FieldArray.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
FieldArray or structured np.ndarray
|
The array of records to append. Must have named fields matching a subset of the current array's fields. |
required |
filtered ¶
filtered(selector, *, copy=False)
Return a FieldArray containing only the selected records.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
selector
|
array‑like, slice or int
|
Any valid NumPy 1‑D index: boolean mask, integer index/array, or slice.
It is applied to the current valid part of the buffer
( |
required |
copy
|
bool
|
|
False
|
Returns:
Type | Description |
---|---|
FieldArray
|
A new instance holding exactly |
from_bl_attributes ¶
from_bl_attributes(bl_attributes)
Import attributes from a Blender attribute collection.
Reads geometry attributes from a Blender data-block and creates/updates the corresponding domain attributes, resizing the domain if needed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bl_attributes
|
Mapping[str, Any]
|
Blender attributes collection (name → attribute descriptor) providing
at least |
required |
Returns:
Type | Description |
---|---|
None
|
|
> ***Note:*** Only external (non-internal) Blender attributes matching this
|
|
domain are imported. Missing attributes are created with `transfer=True`.
|
|
from_dict
classmethod
¶
from_dict(data)
Build a FieldArray from a dictionary with field data and optional metadata.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict[str, array - like or (array, dict)]
|
Mapping field names to arrays or (array, infos). Infos must include NAME. |
required |
copy
|
bool
|
Whether to copy the data. Default: True. |
required |
Returns:
Type | Description |
---|---|
FieldArray
|
|
get ¶
get(name, default=None, broadcast_shape=None)
Get attribute by name.
If name is not an actual field, return default value. Name can be an array.
pos = field_array.get("position", (0, 0, 1))
pos = field_array.get([[0, 0, 1], [0, 0, 0]])
get_rotation ¶
get_rotation(default=None)
Return the per-point rotation or a default.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
default
|
Any or None
|
Value to return if no rotation field is present. If |
None
|
Returns:
Type | Description |
---|---|
Any or None
|
|
See Also
init_kinematics ¶
init_kinematics()
Create standard kinematics fields (linear & angular).
Declares common per-point kinematics attributes for simulation or procedural animation. This method does not modify positions or velocities; it only ensures attributes exist with sensible defaults.
Declared attributes
speed : (N, 3) float Linear velocity. accel : (N, 3) float Linear acceleration. mass : (N,) float, optional Point mass (default 1.0). force : (N, 3) float Accumulated external force. moment : (N,) float, optional Rotational inertia proxy (scalar; simplification). omega : (N, 3) float, optional Angular velocity (radians/second). torque : (N, 3) float, optional Accumulated external torque. age : (N,) float, optional Age/time since spawn (seconds). locked : (N,) bool, optional Freeze flag for constraints/solvers. last_pos : (N, 3) float, optional Previous position (for finite differences). viscosity : (N,) float, optional Linear damping factor.
Returns:
Type | Description |
---|---|
None
|
|
join_attributes ¶
join_attributes(other)
Merge trans-domain attributes from another domain.
Copies or aligns attributes from other
into the current domain, excluding
any attributes not flagged as trans-domain in other
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
Domain or None
|
Source domain. If |
required |
Returns:
Type | Description |
---|---|
Domain
|
The domain itself (for chaining). |
join_fields ¶
join_fields(other, exclude=[])
Add all missing fields from another FieldArray.
For every field in other
that is not present in self
, a new field is created
with the same dtype and shape, and initialized with its default value across all existing records.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
FieldArray
|
Another FieldArray instance whose fields will be checked for missing fields. |
required |
Returns:
Type | Description |
---|---|
self
|
|
line_dist ¶
line_dist(point0=(-1, -1, -1), point1=(1, 1, 1), count=10, density=None, seed=None)
see distributions in maths.distribs
make_buckets ¶
make_buckets(attr)
Group items into buckets by attribute value.
When a domain is to be considered as a collection of packets of various sizes, buckets mechanism groups pakets by size, allowing further operation with numpy vectorization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attr
|
array - like or str
|
Either an integer of shape |
required |
Returns:
Type | Description |
---|---|
list[ndarray(count, n)]
|
A list of int arrays (count, n): count is the number of buckets of length n. |
Examples:
buckets = mesh.make_buckets('material')
for bucket in buckets:
print(bucket.shape)
Note: The bucket attribute can be read with
attr[bucket[:, 0]]
.
multiply ¶
multiply(count)
Duplicate the current records count
times.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
Number of times to repeat the current records. |
required |
Notes
This duplicates the current valid records (up to self._length). If the array is empty or count <= 1, nothing happens.
Example:
If the array has 3 records and count == 4, the result will be:
[rec0, rec1, rec2, rec0, rec1, rec2, rec0, rec1, rec2, rec0, rec1, rec2]
new_attribute ¶
new_attribute(name, data_type, default, optional=False, transfer=True, transdom=True)
Register a new attribute in the domain schema.
Creates (or ensures) an attribute with a given name, logical data type, default value, and flags controlling Blender transfer and cross-domain propagation.
Note:
data_type
argument is a Blender data type not a python data type. The data type name is compatible with Blender internal storage.FLOAT
data type is implemented asnp.float32
and 'INT' asnp.int32
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Attribute name (Python identifier recommended). |
required |
data_type
|
(FLOAT, INT, BOOL, VECTOR, VECTOR2, COLOR, QUATERNION, MATRIX, STRING, ...)
|
Logical data type used by the domain. |
'FLOAT'
|
default
|
Any
|
Default value for newly allocated elements. |
required |
optional
|
bool
|
If |
False
|
transfer
|
bool
|
If |
True
|
transdom
|
bool
|
If |
True
|
See Also
new_float
, new_vector
, new_int
, new_bool
, new_color
, new_vector2
,
new_quaternion
, new_matrix
new_bool ¶
new_bool(name, default=False, optional=False, transfer=True, transdom=True)
Create or ensure a boolean attribute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Attribute name. |
required |
default
|
bool
|
Default value. |
False
|
optional
|
bool
|
|
False
|
transfer
|
bool
|
|
True
|
transdom
|
bool
|
|
True
|
new_color ¶
new_color(name, default=(0.5, 0.5, 0.5, 1.0), optional=False, transfer=True, transdom=True)
Create or ensure a color attribute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Attribute name. |
required |
default
|
array-like of shape (3,) or (4,)
|
Default color as RGB or RGBA. |
(0.5, 0.5, 0.5, 1.0)
|
optional
|
bool
|
|
False
|
transfer
|
bool
|
|
True
|
transdom
|
bool
|
|
True
|
new_field ¶
new_field(name, dtype, shape=None, default=0, optional=False, **infos)
Add a field to the structured array.
Arguments
- name (str) : field name
- dtype (type) : a valid numpy dtype
- shape (tuple = None) : the shape of the field
- default (any = 0) : default value
- optional (bool = False) : the field is created only when accessed
- infos (dict) : field infos
new_float ¶
new_float(name, default=0.0, optional=False, transfer=True, transdom=True)
Create or ensure a scalar float attribute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Attribute name. |
required |
default
|
float
|
Default value. |
0.0
|
optional
|
bool
|
|
False
|
transfer
|
bool
|
|
True
|
transdom
|
bool
|
|
True
|
new_int ¶
new_int(name, default=0, optional=False, transfer=True, transdom=True)
Create or ensure an integer attribute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Attribute name. |
required |
default
|
int
|
Default value. |
0
|
optional
|
bool
|
|
False
|
transfer
|
bool
|
|
True
|
transdom
|
bool
|
|
True
|
new_matrix ¶
new_matrix(name, default=np.eye(4), optional=False, transfer=True, transdom=True)
Create or ensure a matrix attribute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Attribute name. |
required |
default
|
array - like
|
Default matrix. By convention this is a square matrix per element
(e.g., |
np.eye(4)
|
optional
|
bool
|
|
False
|
transfer
|
bool
|
|
True
|
transdom
|
bool
|
|
True
|
order
|
|
required |
new_quaternion ¶
new_quaternion(name, default=(0.0, 0.0, 0.0, 1.0), optional=False, transfer=True, transdom=True)
Create or ensure a quaternion attribute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Attribute name. |
required |
default
|
array-like of shape (4,)
|
Default quaternion in |
(0.0, 0.0, 0.0, 1.0)
|
optional
|
bool
|
|
False
|
transfer
|
bool
|
|
True
|
transdom
|
bool
|
|
True
|
new_vector ¶
new_vector(name, default=(0.0, 0.0, 0.0), optional=False, transfer=True, transdom=True)
Create or ensure a 3D vector attribute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Attribute name. |
required |
default
|
array-like of shape (3,)
|
Default XYZ vector. |
(0.0, 0.0, 0.0)
|
optional
|
bool
|
|
False
|
transfer
|
bool
|
|
True
|
transdom
|
bool
|
|
True
|
new_vector2 ¶
new_vector2(name, default=(0.0, 0.0), optional=False, transfer=True, transdom=True)
Create or ensure a 2D vector attribute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Attribute name. |
required |
default
|
array-like of shape (2,)
|
Default XY vector. |
(0.0, 0.0)
|
optional
|
bool
|
|
False
|
transfer
|
bool
|
|
True
|
transdom
|
bool
|
|
True
|
pie_dist ¶
pie_dist(radius=1, outer_radius=None, center=None, normal=None, pie_center=0.0, pie_angle=np.pi / 2, use_vonmises=False, count=10, density=None, seed=None)
see distributions in maths.distribs
shake_speed ¶
shake_speed(speed, scale=None, length_only=False, seed=None)
Add random jitter to existing velocity vectors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
speed
|
str or ndarray
|
A field name or an array of velocity vectors to perturb. |
required |
scale
|
float or (3,) or None
|
Jitter amount (broadcastable). |
None
|
length_only
|
bool
|
If |
False
|
seed
|
int or None
|
|
None
|
Returns:
Type | Description |
---|---|
ndarray of shape ``(N, 3)``
|
Jittered velocity vectors. |
Raises:
Type | Description |
---|---|
ValueError
|
If inputs are invalid (propagated from the backend). |
See Also
speed_along ¶
speed_along(speed=1, direction=(0, 0, 1), angle=np.pi / 2, scale=None, use_vonmises=False, seed=None)
Sample velocity vectors within a cone around a direction.
Returns random 3D vectors with magnitudes given by speed
and directions
sampled within a cone of half-angle angle
around direction
. Useful to
initialize per-point velocities.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
speed
|
float or (N,) or (N, 3)
|
Target magnitudes (broadcastable). |
1
|
direction
|
(3,) or (N, 3)
|
Cone axis per point (broadcastable). |
(0, 0, 1)
|
angle
|
float
|
Cone half-angle (radians). |
pi/2
|
scale
|
(3,) float or None
|
Optional anisotropic scaling of the cone. |
None
|
use_vonmises
|
bool
|
If |
False
|
seed
|
int or None
|
|
None
|
Returns:
Type | Description |
---|---|
ndarray of shape ``(N, 3)``
|
Sampled velocity vectors. |
Raises:
Type | Description |
---|---|
ValueError
|
If inputs cannot be broadcast/aligned (propagated from the backend). |
sphere_dist ¶
sphere_dist(radius=1.0, scale=None, center=(0, 0, 0), count=10, density=None, seed=None)
see distributions in maths.distribs
to_bl_attributes ¶
to_bl_attributes(attributes, update=False)
Export attributes to a Blender attribute collection.
Writes eligible domain attributes to a Blender data-block, creating missing attributes and adjusting sizes as needed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attributes
|
Any
|
Blender attributes collection receiving the values. |
required |
update
|
bool
|
If |
False
|
Returns:
Type | Description |
---|---|
None
|
|
> ***Caution:*** Only attributes with `transfer=True` are exported. Optional
|
|
attributes are skipped.
|
|
> ***Caution:*** Curve domains user attributes are not saved.
|
|
to_dict ¶
to_dict(*, copy=True, with_infos=True)
Convert the array to a dictionary of fields or (field, infos) pairs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
copy
|
bool
|
Whether to copy the arrays. |
True
|
with_infos
|
bool
|
If True, return (array, infos) for each field. |
True
|
Returns:
Type | Description |
---|---|
dict[str, array or (array, dict)]
|
|
transfer_attributes ¶
transfer_attributes(other, shape=None, other_shape=None)
Transfer values of trans-domain attributes from another domain.
Copies values for each trans-domain attribute present in other
into the
corresponding attributes of self
, with optional reshaping for batched
assignments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
Domain
|
Source domain providing attribute values. |
required |
shape
|
tuple of int or None
|
Target reshape for |
None
|
other_shape
|
tuple of int or None
|
Source reshape for |
None
|
Returns:
Type | Description |
---|---|
Domain
|
The domain itself (for chaining). |
> ***Note:*** Each attribute is reshaped as `shape + item_shape` on `self`
|
|
and `other_shape + item_shape` on `other` prior to assignment.
|
|
transform ¶
transform(transfo, pivot=None)
Transform positions and compose stored orientation.
First applies the linear transform to position
via the base implementation
([transform
][npblender.PointDomain.transform]). Then, if a rotation
field exists (euler
or quat
), composes it with transfo
’s rotation
component and writes back to the same representation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transfo
|
array - like or object
|
Transform(s) broadcastable to the domain size. Typical shapes include
|
required |
pivot
|
array-like of shape ``(..., 3)`` or None
|
Pivot location(s). If |
None
|
Returns:
Type | Description |
---|---|
Point
|
Self (for chaining). |
Raises:
Type | Description |
---|---|
ValueError
|
If broadcasting cannot align inputs with the domain (raised by
[ |
TypeError
|
If |
translate ¶
translate(translation)
Translate points position by a vector or a batch of vectors.
Supports per-domain translation (single vector), or grouped/batched translations that broadcast over buckets of equal size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
translation
|
array-like of shape ``(..., 3)``
|
Translation vectors broadcastable to the domain size. |
required |
Returns:
Type | Description |
---|---|
PointDomain
|
Self (for chaining). |
Examples:
# Per-point random translation
D.translate(np.random.uniform(-0.1, 0.1, (len(D), 3)))
```python
# A mesh made of 8 cubes
cubes = Mesh.cube(size=.2)*8
tr = np.random.uniform(-1, 1, (8, 3))
# Translate each cube individually
cubes.points.translate(tr)
Caution: If a provided batch cannot be aligned with the domain, a
ValueError
is raised by [_get_shape_for_operation
][npblender._get_shape_for_operation].