# PrincipleGeometric transformations Examples Associated transformations Virtual laser

## Principe

### Méthode directe

Syntax:
transf(p)obj(id)
transf is a geometric transformation.
p is a list of characteristic parameters of this transformation. For example an angle for rotation, 3 coefficients for expansion , three coordinates for movement.
obj is a standard object.
The coordinates of the object id are changed from their previous positions:
poi = transf(poi).

Options:
Default transformations are from the previous position.
ini: successive transformations will be from a copy of the original points and are not cumulative in this case:
poi = transf(copie).
max: only transforms the points referenced in the facets (excluding anchors).
validate: the copy is replaced by the transformed points:
copy = poi = transf(poi).

Examples:
`rotx(PI/4)vol(1);` rotates volume 1 of angle PI/4 around x axis.
`rotx(PI/4)vol(1);roty(PI/3)vol(1)`: rotates volume 1 of angle PI/4 around x axis then rotate the result of PI / 3 about the y axis.
`rotx(PI/4)vol(1)ini;roty(PI/3)vol(1)`: Doing the same thing, but from a copy of the original points.
`rotx(PI/4)vol(1)ini;roty(PI/3)vol(1)validate`: Doing the same thing, but transforming the original copy points.
To validate the copy points can be also: validate(1)poi vol(id).
See an example in using the function `set_PAR()` du fichier corps_simple.func.

### Method by the matrix

Syntax:
transf(p)matrix obj(id)
transf id a linear transformation: tran, dila, dilx, dily, dilz, hom, rota, axis, rotx, roty, rotz.
p is a list of characteristic parameters of this transformation.
obj is a standard object.
Only the matrix of object id is modified. Faster but does not allow no linear transformations or only on certain points.
This transformation will be sent to all the followers of the object id.
Options:
ini: Parameter (initially zero) processing base that will be added to the current settings (allows to define standard objects, to modify them and then animate). Note that this ini option does not have the same meaning in the direct method.
Note:
The boxes and ball are not affected by these changes, however attach generate [box ball] vol(id) et attach displ [box ball] vol(id) take them into account.

## Geometric transformations

### Transformations

Any object can be changed by one of the transformations:

adjust: adjustement.
alea: reproductible random.
alex: x random.
aley: y random.
alez: z random.
tran: displacement (translation).
dila: dilatation.
dilx: x dilatation.
dily: y dilatation.
dilz: z dilatation.
hom: homothety.
rand: no reproductible random
rota: rotation.
rotx: x rotation.
roty: y rotation.
rotz: z rotations.
sphere: spherical deformation
syma: symétries.
symx: symmetry x.
symy: symmetry y.
symz: symmetry z.

### Options

mouse(s) s is a multiplier of the mouse.
Réalise transf(s*mouse)
mouse(s)normal
Realizes transf(s*(mouse normalized between -0.5 and 0.5))
mouse(s)normal(x1,y1,x2,y2)
Realizes transf(s*(mouse normalized between (x1,y1) and (x2,y2)))
mouse(s)frame(x1,y1,x2,y2)
Displays frame (x1,y1,x2,y2) and addresses only the points inside this frameet.

### Transformation applied to some vertices

transf(p)obj(id)vertex(s);
In this case the options allow to vary the parameters p between p1 and p2 as a function of the index of the vertex s ist lin s.
acc: accelerated;
dec: decelerated
pend: pendular
cos: cosinusoidal
sin: sinusoidal
law(w)
Example:
`dila(.5,.5,.5,2,2,2)vertex[1,12]vol(1)pend;`
Expands the vertices 1-12 of volume number 1 in a pendular manner between 0.5 and 2.0.

## Examples

tran(200,100,0)vol(1)
Moves the volume number 1 by (200,100,0)
sphere vol(3) poi(0,100) radius(100)
Applies the tool sphere center (0,100,0) and radius 100 atvolume number 3.
Note:
transf object(id) abs
Processes only meaningful points on anchored volumes.

## Associated transformations

### T1(p11,p12)vol(id1)T2(p21,p22)vol(id2)

When parameter of the transformation T2 of volume id2 varies between p21 and p22, the parameter of the transformation T1 of volume id1 varies between p11 and p12.

### Examples

`roty(-P/2,PI/2)vol(1)rotz(-PI,PI)vol(2)`
The volume 1 rotates between -PI/2 and PI/2 around axis y when the volume 2 rotates between -PI and PI around axis z.
`tran(-200,0,0, 200,0,0)vol(1)rotz(-PI,PI)vol(2)`
Volume 1 is translated between (-200,0,0) and (200,0,0) when volume 2 rotates between -PI and PI around axis y.

### Attach of associated transformations

The attach command encapsulates associated transformations, see an example in the fonction func_TRA_ROTZ_ROTZ() of file demo1_attach.func:
`attach(0)rotz(a1,a2)vol(a)rotz(b1,b2)vol(b);`
With yes attach active, volume a will rotate z in interval [a1,a2] when volume rotates z in interval [b1,b2].

## Virtual laser

The laser method is to simulate a virtual laser scanning real volume by rotating a radius in a horizontal plane and intersecting vertically moving these volumes.
The simulation has no reason to limit the movement of the beam, it can be from any source and target another point located on the axis and in the plane perpendicular to the axis passing through the source. For example, the target point can explore concavities of the object scanned.
The set of sources is not necessarily a cylinder but may be generalized box (generated by parametric curves around to better volume).
Similarly, the set of points of view is not necessarily an axis but may be a curve (eg all secy CG of the box).
Command envelope vol allows to control by program such a virtual laser.