DInsight Home
Transforms

# 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 iFrame3_f is IFrame3 implemented by f, the global coordinates of the transformed point are obtained by iFrame3_f.ToGlobal(x,y,z)

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

Similarily, 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 iFrame3_f.ToGlobalVector(vx,vy,vz)

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

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

## Constructing basic transforms

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

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

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

To obtain transformation of a rotation:

iFrame3_f.Reset();
iFrame3_f. 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 obvious multiplication (composition) operation: f*g(point) = f(g(point)). The identical transform is a unit relative to this operation. Inverse tarnsfrom is a transfrom 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.

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

iFrame3_f0.ToGlobalFrame(iFrame3_f1);

after which iFrame3_f1 becomes product of the two.

To keep iFrame3_f0 unchanged, create a new iFrame3_f:
IDIObjGenerator iGener = (IDIObjGenerator)iModel;
IFrame3 iFrame3_f = iGener.Create(eObjTypeFrame);
iFrame3_f.Copy(iFrame3_f1);
iFrame3_f0.ToGlobalFrame(iFrame3_f);

## Transforming 3D objects

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

### Moving the object as whole

This is the preferred way of moving objects 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 (mesh) size as only the local frame is modified.

This type of transformation can be executed with:

IFrame3 iFrame3 = (IFrame3)iSection;
iFrame3_f.ToGlobalFrame(iFrame3);

### Transforming surface

Internal transformations are not possible for all types of objects. It is always possible for Mesh Sections

To apply a generic transform IFrame iFrame_f use:

ITransform iTransf = (ITransform)iSection;
iTransf.Apply(iFrame_f, false);

ITransform.TranslateLoc(), ITransform.RotateLoc(), ITransform.ScaleLoc() allow performing basic transformations.

Transforming surface means operations on all elements of the geometry (mesh), which means it can be computationaly expensive. 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 to the surface

Transforming surface is inevitable when there is need to modify location 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). This is what is happening when the second parameter of ITransform.Apply() is true