gdpc.transform¶
Provides the Transform class and related functions
- class Transform¶
Represents a transformation of space.
When applied to a vector,
flipis applied first,rotationsecond, andtranslationthird.Note that only the four 90-degree rotations in the XZ-plane are supported. Hence,
rotationshould be 0, 1, 2 or 3. A rotation of 1 rotates (1,0,0) to (0,0,1). In Minecraft’s coordinate system, this is clockwise.-
__init__(translation: Vec3iLike =
ivec3(0, 0, 0), rotation: int =0, flip: Vec3bLike =bvec3(0, 0, 0))¶ Constructs a Transform with the given properties.
- property translation : ivec3¶
The translation component of this transform
- property flip : bvec3¶
The flip component of this transform
- invApply(vec: Vec3iLike) ivec3¶
Applies the inverse of this transform to
vec.Faster version of
~self * vec.
- compose(other: Transform) Transform¶
Returns a transform that applies
selfafterother.Equivalent to
self @ other.
- invCompose(other: Transform) Transform¶
Returns a transform that applies
~selfafterother.Faster version of
~self @ other.
- composeInv(other: Transform) Transform¶
Returns a transform that applies
selfafter~other.Faster version of
self @ ~other.
- push(other: Transform) None¶
Adds the effect of
otherto this transform.Equivalent to
self @= other.
- pop(other: Transform) None¶
The inverse of push. Removes the effect of
otherfrom this transform.Faster version of
self @= ~other.
- __matmul__(other: Transform) Transform¶
@operator. Returns a transform that appliesselfafterotherEquivalent to
self.compose(other)
- __mul__(vec: Vec3iLike) ivec3¶
*operator. Applies this transform tovecEquivalent to
self.apply(vec)
- __imatmul__(other: Transform) Transform¶
@=operator. Adds the effect ofotherto this transform.Equivalent to
self.push(other)
-
__hash__ =
None¶
- __invert__() Transform¶
~operator. Returns the inversion of this transform.Equivalent to
self.inverted().
-
__match_args__ =
('_translation', '_rotation', '_flip')¶
-
__init__(translation: Vec3iLike =
- TransformLike¶
A class is a TransformLike if it is a
Transformor aVec3iLike, the latter being interpreted as a translation.
- toTransform(transformLike: TransformLike) Transform¶
Converts
transformLiketo aTransform, interpreting a vector as a translation.This function is mainly for internal use in GDPC, but may also be useful in user programs.
Functions that take a Transform parameter are very often called with just a translation. By taking a TransformLike pararameter instead and using this converter, calling such a function with just a translation becomes slightly easier. This does however cost a bit of performance (for an
isinstancecall).
- rotatedBoxTransform(box: Box, rotation: int) Transform¶
Returns a transform that maps the box
((0,0,0), size)toboxunderrotation, wheresize == vector_tools.rotateSize3D(box.size, rotation).