Performing Transforms

createTransformation

Creates a new Transformation object (t) that can be used to transform a shape (Wire, face, Solid etc). This is a more of generic method that lets you specify more than one type of transformation in one call. Refer to other methods that allow only one type of transform.

Note: When your intent is to use objects center as center of transform, use a flavor that captures only transformation information. If you intend to use a particular point for rotation, then construct a transform that lets you specify center and Qauternion.

Syntax

cadlib.createTransformation( { position: {x, y,z }, quaternion: { x, y, z, w}, scale: { factor: N } } );

Parameters

Name Type Description
position Vec3 Optional. Include this to add positional transformation
quaternion Quaternion Optional. Include this to add rotation transformation (x, y, z, w). w is in Radians and must be greater than 0
scale Object Optional. Include to specify scaling factor.

Returns

Transform

Example

Check the example here


createRotationTransform

Construct a rotation transformation using center of rotation, axis and angle information.

Note: Use this method when you want rotation around a specific point (center).

Syntax

cadlib.createRotationTransform( center, axis, angle );

Parameters

Name Type Description
center Vector3 center of rotation
axis Vector3 axis of rotation
angle Number rotation angle

Returns

Transformation


crateQuaternionTransform

Create a rotation transform using the specified Quaternion. Supply value for center point if rotation around a specific point is needed. Otherwise, objects center will be used.

Syntax

cadlib.crateQuaternionTransform(quanternion, center);

Parameters

Name Type Description
quaternion [Quaternion] Include this to add rotation transformation (x, y, z, w). w is in Radians and must be greater than 0
center Vec3 Center of rotation

Returns

Transformation(./)


createTranslationTransform()

Creates a translation transform.

Syntax

cadlib.createTranslationTransform(x, y, z);

Parameters

Name Type Description
x Point Translation along X axis
y Point Translation along Y axis
z Point Translation along Z axis

Returns

Transformation


createMrrorAxisTransform()

Used to mirror an solid around an axis with specified center

Syntax

cadlib.createMrrorAxisTransform(center, axis);

Parameters

Name Type Description
center Point Center point for the mirror
axis Vec3 Mirror Axis

Returns

Transformation Object


createScaleTransform()

Use this transform to scale an solid.

Syntax

cadlib._createScaleTransform(factor, center);

Parameters

Name Type Description
factor Number Scaling factor. Solid will be scaled uniformly
center Pont center of scaling

Returns

Transformation Object


scale()

Use this method to scale a solid.

Note: This method accepts a shape/solid unlike createScaleTransform

Syntax

cadlib.scale(shape, factor, center);

Parameters

Name Type Description
shape [Face, Wire, Edge, Solid] Shape to scale
factor Number Scaling factor. Solid will be scaled uniformly
center Pont center of scaling

Returns

Shape – Returns scaled shape (Face, Wire, Edge or Solid)