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.

x: float
y: float
z: float
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).

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. The dazpy API (DazNode.rotation, DazBone.local_rotation) returns the same dict shape but with Studio’s DzQuat convention, which is the conjugate: convert with from_dz() / to_dz().

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.

x: float
y: float
z: float
w: float
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, components taken as-is.

For a quaternion read from Studio (rotation, local_rotation, getOrientation()) use from_dz() instead: a DzQuat stores the conjugate.

classmethod from_dz(d)[source]

Create from a DAZ Studio DzQuat dict.

A DzQuat stores the conjugate (-x, -y, -z, w) of the math3 quaternion for the same rotation (live-verified for getLocalRot, getWSRot and getOrientation; DzQuat.multVec rotates vectors like rotate() on the converted value). Use this for rotation and local_rotation.

to_dz()[source]

Return the DzQuat dict for this rotation (inverse of from_dz()).

classmethod from_dz_euler(x, y, z, rotation_order='XYZ', orientation=None)[source]

The local rotation Studio produces from rotation channel values.

Studio’s rotation order string (getRotationOrder(), e.g. "YZX") is the reverse of math3’s order, and the channels rotate about the bone’s oriented axes, so local = O * from_euler(x, y, z, reversed_order) * O⁻¹. Live-verified against getLocalRot() on Genesis 9 bones and cameras.

Parameters:
  • x (float) – X rotation channel value in degrees (as applied, after limits).

  • y (float) – Y rotation channel value in degrees.

  • z (float) – Z rotation channel value in degrees.

  • rotation_order (str) – Studio’s order string (rotation_order). Nodes such as cameras report "XYZ".

  • orientation (Quat | None) – The node’s orientation as a math3 quaternion, i.e. Quat.from_dz(<getOrientation() dict>). None for identity.

Returns:

The math3 quaternion equal to Quat.from_dz(<getLocalRot()>).

Return type:

Quat

to_dz_euler(rotation_order='XYZ', orientation=None)[source]

Rotation channel values (x, y, z) that reproduce this local rotation.

Inverse of from_dz_euler(); pass the values to set_local_rotation(). Joint limits are not applied.

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. This is the reverse of Studio’s rotation_order string; to convert Studio channel values use from_dz_euler().

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

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.

min: Vec3
max: Vec3
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.

AxisRemap

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

Bases: object

Converts Vec3, Quat, and BoundingBox values between axis conventions (e.g. Y-up to Z-up).

A generic signed-axis-permutation remap — no application-specific knowledge (Blender/Unreal naming, camera or figure orientation fixups) is baked in beyond the Y_UP_TO_Z_UP preset.

Each of x, y, z names which source axis (optionally signed) the corresponding output axis is derived from. All three of the source axes x, y, z must be referenced exactly once (signs aside).

Example:

# DAZ Studio (Y-up) -> Blender-style Z-up
remap = AxisRemap(x="x", y="-z", z="y")
blender_pos = remap.apply_vec3(daz_pos)
Parameters:
  • x (str) – Source axis for the output X component, e.g. "x" or "-z".

  • y (str) – Source axis for the output Y component.

  • z (str) – Source axis for the output Z component.

apply_vec3(v)[source]

Remap a vector or point. Works for any remap, proper or reflective.

apply_quat(q)[source]

Remap a rotation.

Raises:

ValueError – If this remap is a reflection (determinant -1). Reflections cannot be represented by a quaternion; use apply_vec3() for vectors/points instead.

apply_bbox(b)[source]

Remap a bounding box.

Both corners are remapped and the result is re-sorted per axis, since a sign-flipping remap can swap which corner is the minimum on a given axis.

dazpy.Y_UP_TO_Z_UP = AxisRemap(x='x', y='-z', z='y')

Converts Vec3, Quat, and BoundingBox values between axis conventions (e.g. Y-up to Z-up).

A generic signed-axis-permutation remap — no application-specific knowledge (Blender/Unreal naming, camera or figure orientation fixups) is baked in beyond the Y_UP_TO_Z_UP preset.

Each of x, y, z names which source axis (optionally signed) the corresponding output axis is derived from. All three of the source axes x, y, z must be referenced exactly once (signs aside).

Example:

# DAZ Studio (Y-up) -> Blender-style Z-up
remap = AxisRemap(x="x", y="-z", z="y")
blender_pos = remap.apply_vec3(daz_pos)
Parameters:
  • x – Source axis for the output X component, e.g. "x" or "-z".

  • y – Source axis for the output Y component.

  • z – Source axis for the output Z component.