Math & Geometry Types

Vec3

class dazpy.Vec3(x, y, z)[source]

Bases: object

Immutable 3-component vector.

All arithmetic operators return new Vec3 instances.

Parameters:
  • x (float) – X component.

  • y (float) – Y component.

  • z (float) – Z component.

classmethod from_dict(d)[source]

Create from an {"x", "y", "z"} dict (e.g. from position).

classmethod from_list(v)[source]

Create from a [x, y, z] list (e.g. a vertex from vertex_positions_all()).

classmethod zero()[source]

Return the zero vector (0, 0, 0).

to_dict()[source]

Return {"x": float, "y": float, "z": float}.

to_list()[source]

Return [x, y, z].

dot(other)[source]

Dot product.

cross(other)[source]

Cross product (right-hand rule).

length_sq()[source]

Squared length (avoids a sqrt).

length()[source]

Euclidean length.

normalize()[source]

Return a unit-length copy. Returns the zero vector unchanged.

distance_sq(other)[source]

Squared distance to other.

distance(other)[source]

Euclidean distance to other.

lerp(other, t)[source]

Linearly interpolate toward other. t=0 → self, t=1 → other.

reflect(normal)[source]

Reflect this vector about normal (normal must be unit length).

x
y
z

Quat

class dazpy.Quat(x, y, z, w)[source]

Bases: object

Unit quaternion representing a 3D rotation.

Stored as (x, y, z, w) — imaginary components first, scalar last. This matches the dict format returned by the dazpy API (DazNode.rotation, DazBone.local_rotation).

All methods return new Quat instances. The object is immutable.

Parameters:
  • x (float) – i component.

  • y (float) – j component.

  • z (float) – k component.

  • w (float) – Scalar component.

classmethod identity()[source]

Return the identity quaternion (0, 0, 0, 1) (no rotation).

classmethod from_dict(d)[source]

Create from an {"x", "y", "z", "w"} dict (e.g. from rotation).

classmethod from_euler(x, y, z, order='XYZ')[source]

Create from Euler angles in degrees using intrinsic rotations.

Intrinsic means each rotation is applied in the frame left by the previous rotation — the same convention DAZ Studio uses for bone rotation channels.

Parameters:
  • x (float) – Rotation around the X axis in degrees.

  • y (float) – Rotation around the Y axis in degrees.

  • z (float) – Rotation around the Z axis in degrees.

  • order (str) – Application order — one of XYZ, XZY, YXZ, YZX, ZXY, ZYX. Matches rotation_order.

Returns:

A unit quaternion.

Return type:

Quat

classmethod from_axis_angle(axis, angle_deg)[source]

Create from an axis and angle in degrees.

Parameters:
  • axis (Vec3) – Rotation axis (need not be unit length — normalised internally).

  • angle_deg (float) – Rotation magnitude in degrees.

Returns:

A unit quaternion.

Return type:

Quat

to_dict()[source]

Return {"x": float, "y": float, "z": float, "w": float}.

to_matrix()[source]

Return the equivalent 3×3 rotation matrix (row-major, right-handed).

to_euler(order='XYZ')[source]

Extract Euler angles in degrees.

The inverse of from_euler() for the same order. Gimbal-lock configurations (singularities) are handled by setting the last rotation in the order to zero.

Parameters:

order (str) – One of XYZ, XZY, YXZ, YZX, ZXY, ZYX.

Returns:

(x, y, z) in degrees.

Return type:

tuple[float, float, float]

multiply(other)[source]

Hamilton product self * other.

Composing rotations: a.multiply(b) applies a first, then b in the rotated frame (intrinsic), or equivalently b first then a in the world frame (extrinsic).

conjugate()[source]

Return the conjugate (-x, -y, -z, w).

length()[source]

Quaternion norm.

normalize()[source]

Return a unit-length copy.

dot(other)[source]

4D dot product (used internally by slerp()).

rotate(v)[source]

Rotate vector v by this quaternion.

Uses the sandwich product q * v * q⁻¹.

slerp(other, t)[source]

Spherical linear interpolation.

Always takes the shortest arc between the two orientations.

Parameters:
  • other (Quat) – Target rotation (t=1.0 produces an exact copy of other).

  • t (float) – Blend factor in [0, 1].

Returns:

A unit quaternion at the interpolated orientation.

Return type:

Quat

x
y
z
w

BoundingBox

class dazpy.BoundingBox(min, max)[source]

Bases: object

Axis-aligned bounding box.

Parameters:
  • min (Vec3) – Corner with the smallest coordinates.

  • max (Vec3) – Corner with the largest coordinates.

classmethod from_dict(d)[source]

Create from the dict returned by bounding_box().

Expected shape: {"min": {"x":..., "y":..., "z":...}, "max": {...}}.

classmethod from_points(points)[source]

Compute the tight bounding box around a list of Vec3 points.

to_dict()[source]

Return {"min": {...}, "max": {...}}.

property center: Vec3

Geometric center of the box.

property size: Vec3

Width, height, and depth as a Vec3.

property volume: float

Signed volume (positive for valid boxes where min ≤ max on all axes).

contains(point)[source]

Return True if point is inside or on the surface of the box.

overlaps(other)[source]

Return True if this box and other share any volume.

expand(amount)[source]

Return a box uniformly expanded by amount on all sides.

union(other)[source]

Return the smallest box that contains both this box and other.

min
max