Class: Transformation

Transformation lets you move, rotate, scale, mirror, and shear geometry in 3D space. Transformations are chainable -- you can build up a compound transform step by step and then apply it to points, vectors, planes, curves, or surfaces.

When to use

  • Positioning objects -- translate and rotate solids or surfaces into their final locations.
  • Creating patterns -- apply repeated transformations to produce arrays, circular patterns, or mirrored copies.
  • Building assemblies -- combine coordinate-system changes and transforms to place parts relative to each other.

Quick start

import { Transformation, Vector } from '@beegraphy/opencascade';

// Translate
const t1 = new Transformation();
t1.translate(new Vector(10, 0, 0));

// Rotate 45 degrees around the origin
const t2 = new Transformation();
t2.rotate(45, new Vector(0, 0, 0));

// Uniform scale by 2x from the origin
const t3 = new Transformation();
t3.scale(new Vector(0, 0, 0), 2);

// Mirror across the YZ plane
const t4 = new Transformation();
t4.mirror('YZ');

// Apply a transform to a point
const moved = t1.transformPoint(new Vector(0, 0, 0));
// moved => Vector(10, 0, 0)

Key methods

MethodDescription
translate(vector)Move by a translation vector
rotate(angle, position)Rotate by an angle (degrees) around a position
scale(center, factor)Uniform scale around a center point
scaleNU(center, fx, fy, fz)Non-uniform scale with separate axis factors
mirror(plane)Mirror across a plane ('XY', 'YZ', 'XZ', or a custom plane)
mirrorCurve(curve)Mirror a curve
mirrorSurface(geom, surface)Mirror a surface
shear(refPoint, targetPoint)Apply a shear transformation
coordSystemChange(from, to)Change between coordinate systems
transformPoint(point)Apply the transformation to a point
applyTransformToVector(vector)Apply the transformation to a vector
applyTransformToPlane(plane)Apply the transformation to a plane

Method: translate

Translates the transformation by the given vector.

Parameters

  • vector (Point): The vector representing the translation.

Returns

The updated Transformation object.

Example

const vector = /* specify a vector */;
const instance = new Transformation();
instance.translate(vector);

Method: rotate

Rotates the transformation by the specified angle around the given position and direction.

Parameters

  • angle (number): The angle of rotation in degrees.
  • position (Point = [0): The position around which the rotation will occur. Defaults to [0, 0, 0].

Returns

The updated Transformation object.

Example

const angle = 0.5;
const position = new Vector(0, 0, 0);
const instance = new Transformation();
instance.rotate(angle, position);

Method: mirror

Mirrors the transformation along a specified plane or point.

Parameters

  • inputPlane (IPlane | PlaneName | Point = 'YZ'): The plane or plane name to mirror the transformation along. Defaults to 'YZ'.

Returns

The transformed object with the mirror applied.

Example

const inputPlane = /* specify a inputPlane */;
const instance = new Transformation();
instance.mirror(inputPlane);

Method: mirrorCurve

Mirrors a curve.

Parameters

  • crv (ICurve): The curve to be mirrored.

Returns

The mirrored curve.

Example

const crv = CurveBuilder.line(new Vector(0, 0, 0), new Vector(1, 1, 1));
const instance = new Transformation();
instance.mirrorCurve(crv);

Method: mirrorSurface

Mirrors a surface based on a given geometry.

Parameters

  • geom (IGeometry): The geometry to mirror.
  • srf (ISurface): The surface to mirror.

Returns

The mirrored surface transformation.

Example

const geom = /* specify a geom */;
const srf = /* specify a srf */;
const instance = new Transformation();
instance.mirrorSurface(geom, srf);

Method: scale

Scales the transformation around the specified center point.

Parameters

  • center (Point): The center point of the scaling operation.
  • scale (number): The scaling factor.

Returns

The modified Transformation object.

Example

const center = new Vector(0, 0, 0);
const scale = 0.5;
const instance = new Transformation();
instance.scale(center, scale);

Method: scaleNU

Scales the transformation around a specified center point.

Parameters

  • center (IVector): The center point of the scaling operation.
  • factorX (number): The scaling factor along the X-axis.
  • factorY (number): The scaling factor along the Y-axis.
  • factorZ (number): The scaling factor along the Z-axis.

Returns

The modified Transformation object.

Example

const center = new Vector(1, 1, 1);
const factorX = 0.5;
const factorY = 0.5;
const factorZ = 0.5;
const instance = new Transformation();
instance.scaleNU(center, factorX, factorY, factorZ);

Method: shear

Applies a shear transformation to the current Transformation object.

Parameters

  • referencePoint (IVector): The reference point for the shear transformation.
  • targetPoint (IVector): The target point for the shear transformation.

Returns

The updated Transformation object after applying the shear transformation.

Example

const referencePoint = new Vector(1, 1, 1);
const targetPoint = new Vector(1, 1, 1);
const instance = new Transformation();
instance.shear(referencePoint, targetPoint);

Method: coordSystemChange

Changes the coordinate system from fromSystem to toSystem.

Parameters

  • fromSystem (CoordSystem): No description
  • toSystem (CoordSystem): No description

Returns

The instance of the Transformation class.

Example

const fromSystem = /* specify a fromSystem */;
const toSystem = /* specify a toSystem */;
const instance = new Transformation();
instance.coordSystemChange(fromSystem, toSystem);

Method: transformPoint

Transforms a given point using the specified transformation.

Parameters

  • point (Point): The point to be transformed.

Returns

The transformed point.

Example

const point = new Vector(0, 0, 0);
const instance = new Transformation();
instance.transformPoint(point);

Method: applyTransformToVector

Applies a transformation to the given vector.

Parameters

  • vector (IVector): The vector to apply the transformation to.

Example

const vector = new Vector(1, 1, 1);
const instance = new Transformation();
instance.applyTransformToVector(vector);

Method: applyTransformToPlane

Applies a transformation to a plane.

Parameters

  • plane (IPlane): The plane to apply the transformation to.

Returns

The transformed plane.

Example

const plane = /* specify a plane */;
const instance = new Transformation();
instance.applyTransformToPlane(plane);

Method: delete

Deletes the transformation and cleans up associated resources.

Example

const instance = new Transformation();
instance.delete();