skppy.data_structure.primitives¶
Vector and transformation primitives used throughout the public model.
Coordinates and translations use SketchUp’s native inch unit. Transform
accepts either the 13-value SketchUp representation or a NumPy 4 x 4 matrix
and provides composition and point/vector conversion helpers.
Example
import skppy
move = skppy.Transform.from_translation(24, 36, 0)
print(move.translation().to_tuple()) # (24.0, 36.0, 0.0)
- class skppy.data_structure.primitives.Transform[source]
Bases:
objectWraps the 13-float SUTransformation used by SketchUp.
Layout (row-major, 3x3 rotation + translation + scale):
Indices 0-2 : first row of the rotation/scale matrix
Indices 3-5 : second row
Indices 6-8 : third row
Indices 9-11: translation (tx, ty, tz) in SketchUp inches
Index 12 : uniform scale factor (normally 1.0)
All spatial values are in SketchUp inches.
- Parameters:
values (sequence of float, numpy.ndarray, optional) – Optional 13-float SketchUp transformation or
(4, 4)matrix.
- __init__(values: Sequence[float] | ndarray | None = None) None[source]
Create a transform from SketchUp’s 13-float layout or a 4x4 matrix.
- Parameters:
values (sequence of float, numpy.ndarray, optional) –
Nonecreates the identity transform. A flat sequence is interpreted as SketchUp’s 13-float row-major transform layout (3x3 basis, translation, homogeneous scale). A(4, 4)NumPy array is copied directly.
- classmethod from_rotation_x(radians: float) Transform[source]
Build a rotation around the X axis.
- Parameters:
radians (float) – Rotation angle in radians.
- Return type:
Transform
- classmethod from_rotation_y(radians: float) Transform[source]
Build a rotation around the Y axis.
- Parameters:
radians (float) – Rotation angle in radians.
- Return type:
Transform
- classmethod from_rotation_z(radians: float) Transform[source]
Build a rotation around the Z axis.
- Parameters:
radians (float) – Rotation angle in radians.
- Return type:
Transform
- classmethod from_scale(sx: float, sy: float, sz: float) Transform[source]
Build a non-uniform scale transform around the origin.
- Parameters:
sx (float) – Per-axis scale factors.
sy (float) – Per-axis scale factors.
sz (float) – Per-axis scale factors.
- Return type:
Transform
- classmethod from_translation(tx: float, ty: float, tz: float) Transform[source]
Build a pure translation transform.
- Parameters:
tx (float) – Translation offsets in SketchUp inches.
ty (float) – Translation offsets in SketchUp inches.
tz (float) – Translation offsets in SketchUp inches.
- Return type:
Transform
- classmethod from_uniform_scale(s: float) Transform[source]
Build a uniform scale transform around the origin.
- Parameters:
s (float) – Scale factor applied to all three axes.
- Return type:
Transform
- classmethod identity() Transform[source]
Return the identity transform (no rotation, no translation, scale=1).
- Return type:
Transform
- property matrix: ndarray
Return a copy of the internal 4x4 matrix.
- Returns:
Matrix in row-major order.
- Return type:
numpy.ndarray
- to_list() List[float][source]
Return the raw 13-float list.
- Returns:
Copy of the internal 13-element values list.
- Return type:
list of float
- translation() Vector3D[source]
Extract the translation component of the transform.
- Returns:
The (tx, ty, tz) translation in SketchUp inches.
- Return type:
Vector3D
- class skppy.data_structure.primitives.Vector2D[source]
Bases:
object2-D point or vector.
- x
X component.
- Type:
float
- y
Y component.
- Type:
float
- __init__(x: float, y: float) None
- to_array() ndarray[source]
Return
[x, y]as a NumPy array.- Returns:
Two-element floating-point array.
- Return type:
numpy.ndarray
- class skppy.data_structure.primitives.Vector3D[source]
Bases:
object3-D point or vector (SketchUp internal units = inches).
All geometric positions and directions in skppy are expressed in SketchUp’s internal unit – inches – unless otherwise noted.
- x
X component.
- Type:
float
- y
Y component.
- Type:
float
- z
Z component.
- Type:
float
- __init__(x: float, y: float, z: float) None
- cross(other: Vector3D) Vector3D[source]
Return the cross product with other.
- Parameters:
other (Vector3D) – The other vector.
- Returns:
self x other.- Return type:
Vector3D
- dot(other: Vector3D) float[source]
Return the dot product with other.
- Parameters:
other (Vector3D) – The other vector.
- Returns:
self . other.- Return type:
float
- length() float[source]
Return the Euclidean length (magnitude) of the vector.
- Returns:
sqrt(x^2 + y^2 + z^2).- Return type:
float
- normalized() Vector3D[source]
Return a unit-length copy of this vector.
- Returns:
Unit vector. Falls back to
(0, 0, 1)when the length is near zero (below1e-12).- Return type:
Vector3D
- to_array() ndarray[source]
Return
[x, y, z]as a NumPy array.- Returns:
Three-element floating-point array.
- Return type:
numpy.ndarray
- to_tuple() Tuple[float, float, float][source]
Return
(x, y, z)as a plain tuple.- Returns:
(x, y, z).- Return type:
tuple of float