DG Kernel (ActiveX) Documentation


Skip Navigation Links.
Skip Navigation LinksHome Page > Math Objects > Transforms Go to DGKC docs Search Documentation


Transforms

Each frame f defines a linear transform of 3D space: a point with global 3D coordinates (x, y, z) is mapped to point with same coordinates relative to f. If iFrame is IFrame_DG, implemented by f, the global coordinates of the transformed point are obtained by iFrame.ToGlobal(x,y,z)

This correspondence establishes mapping between frames and invertible transforms which preserve distances and angles

Similarly, a vector (vx,vy,vz) in global coordinates is transformed into vector with same coordinates relative to f and its global coordinates are obtained with iFrame.ToGlobalVector(vx,vy,vz)

A 3D axis can be transformed in the same way, and as the transformation preserves angles this also defines transformation of sets of axes of coordinates in 3D

Frame, which coincides with the global frame, is mapped to identity transformation

Constructing basic transforms

Call iFrame.Reset(); to make f an identity transformation

To obtain transformation of a translation by (vx,vy,vz)  execute:

iFrame.Reset();
iFrame.Translate(vx,vy,vz);

To obtain transformation of a rotation:

iFrame.Reset();
iFrame.Rotate(angle, xAxis, yAxis, zAxis, vxDirAxis, vyDirAxis, vzDirAxis);

where (xAxis, yAxis, zAxis) is a point where the axis passes through and (vxDirAxis, vyDirAxis, vzDirAxis) is the direction of the axis

Multiplication of transforms

Transforms have a multiplication (composition) operation: f*g(point) = f(g(point)). The identical transform is a unit relative to this operation. Inverse transform is a transform g, such that f*g=identity.

Using the above correspondence, this operation can be extended to frames. So frames can be multiplied, inverted and divided.

The product of two frames f = f1*f0 can be obtained with:

iFrame0.ToGlobalFrame(iFrame1);

after which, iFrame1 becomes product of the two. To keep iFrame0 unchanged, clone it using IFrame_DG.Clone():

Transforming 3D objects

There are two significantly different ways of applying transforms to entities: a) Moving the entity as whole without modifying the geometry b) Transforming internal surface of the entity. The second method means that surface of the entity has to be moved relatively to the local frame

Moving the object as whole

This is the preferred way of moving entities around when the surface does not need to be modified in any way, only position and orientation has to be adjusted. This method is very fast and does not depend on geometry size as only the local frame is modified.

This type of transformation can be executed with:

IFrame_DG iFrameEntity = iEntity.GetLocation();
iFrame.ToGlobalFrame(iFrameEntity);

Transforming surface

To apply a generic transform IFrame_DG iFrame, use:

iEntity > IGeometricObject_DGiTransf
iTransf.Transform(iFrame);

IGeometricObject_DG.Translate(), IGeometricObject_DG.Rotate(), etc., are shortcuts for basic transformations.

Transforming surface means operations on all elements of the geometry, which can be computationaly expensive, for example in case of a dense mesh. When there are several consequtive surface transformation required it is much faster to calculate the total transform first by multuplying them in sequence as described above and then apply the result to the surface

Transforming surface is inevitable when there is need to modify position/orientation of the local frame relative to the surface (for more convenient rotations etc.). For example, translating local frame by a vector v means translating the whole object by v and translating the surface by -v (opposite direction).

See also: Transform sample