collision


collisions detection

Principle
anc
ball
coe
collision
force
func
normal
poi
radius
sphere
vol
vol_near
vol_vol
See also

Principle:

In dynamic animation this command allows to manage collisions between objects. If yes dynamic is active and if the objects are equipped with masses some effects can be obtained (bouncing, sliding, friction, etc. ..)
It is necessary to activate collisions by yes collision.
See for example set_anc() function of file demo1_collision.func.

collision anc

collision anc vol(id1)

       Returns the collision anc property of volume id1.

collision anc vol(id1)=id2

       Change this property.
Notes: If id2 belongs to an anchored structure of root id0
the volume id0 will be attracted by volume id1 with a force f = 0.5 * (dist(id1,id2).
Options:
id2,v1,v2: the vertix v2 of volume id2 will coincide with vertex v1 of volume id1 (CG default).

collision anc coe vol(id1)

       Returns the collision anc coe property of volume id1.

collision anc coe vol(id1)=c

       Change this property.
Notes:
the force is timed by c.
to ovoide trembling set a viscosity < 0 to this force, for example:
       force vol(id0)=0,0,0,-.5;

collision ball

collision ball vol(id1)

       Returns the property collision ball of volume id.

collision ball vol(id1)=x,y,z

       Changes this this property.
Note:
vol (id) is the root of an anchoring structure (for example the pelvis of a body).
Defines a ball obstacle center (x, y, z) and radius(r).
Multiple collision balls on the same volume id can be defined by:
collision poi vol(id)=x1,y1,z1, x2,y2,z2, ...
collision radius vol(id)=r1,r2, ...;

collision coe

collision coe vol(id)

       Returns the collision coe property of volume id.

collision coe vol(id)=reb,fric

       Change this property.
Notes:
reb: coefficient of rebound changing the speed after the shock (between 0 and 1).
fric: coefficient of friction, if != 0.0 the rebound occures only if (module(speed) > fric (25 default).

collision collision

collision collision vol(id)

       Returns the collision collision property of volume id.

collision collision vol(id)=id1,id2,...

       Change this property.
Note:
id1,id2,...: are the identifiers of the volumes which react in case of collision (all by default).

collision force

collision force vol(id)

       Returns the force property of volume id.

collision force vol(id)=f,c

       Change this property.
Note:
f: modulates the reaction (0 by default).
c: transmission coefficient (0 by default).
-1,.75 are good values.

collision func

collision func vol(id)

       Returns the collision func property of volume id.

collision func vol(id)="fff"

       Change this property.
Note:
fff is the name of an anyflo function which will be executed each collision of the anchored structure of root the volume id.
Such a function has one formal parameter id.

collision normal

collision normal vol(id)

       Returns the collision normal property of volume id.

collision normal vol(id)=nx,ny,nz

       Change this property.
Notes:
(nx,ny,nz) is the normal to the plan through point colliisin poi vol(id) (0,-1,0 by default).

collision poi

Allows an anchored structure to "walk" (eg body) on a floor.

collision poi vol(id)

       Returns the collision poi property of volume id.

collision poi vol(id)=x,y,z

       Change this property.
Notes:
vol (id) is the root of an anchoring structure (for example the pelvis of a body).
Defines an horizontal obstacle plane passing through the point (x, y, z), to change the orientation see collision normal vol(id).
Multiple collision planes on the same volume id can be defined by:
collision coe vol(id)=reb1,fri1,reac1, reb2,fri2,reac2...;
collision normal vol(id)=nx1,ny1,nz1, nx2,ny2,nz2, ...;
collision poi vol(id)=x1,y1,z1, x2,y2,z2, ...;


Example:
collision coe vol(id)=1,10,.25;
collision normal vol(id)=0,-1,0; collision poi vol(id)=0,0,0;

collision radius

collisionradius vol(id1)

       Returns the property collision radius of volume id.

collision radius vol(id1)=r

       Changes this this property.
Note:
volume (id) has a property collision ball, r is the radius of the ball.

collision sphere

collision sphere vol(id)

        Returns the property collision sphere of volume id type particle.

collision sphere vol(id)=x,y,z,r1,r2,c

        Changes this property.
Note:
if yes collision, yes dynamic and yes particle are active, the points of volume id will rebound, with a coefficient c (1.0 default), on the sphere center (x,y,z) and radius r1
The rebound direction varie form 0 (at r2) to the symetric to the normal, so simulating a fluid.
r1, r2 > 0: outside.
r1, r2 < 0: intside.
r1=r2: non compressible fluid.

collision vol

collision vol(id)

       Returns information collision volume id:
flag,v,s,x0,y0,z0,x,y,z:
        flag = 1: new collision.
        flag = 2: same collision.
        flag = 0: no collision.
        v = collision volume number, s = collision vertex number.
        x0,y0,z0 = old collision position.
        x,y,z = new collision position.
Notes:
Allows determine the point of contact:
c=collision vol(f);
if(c!=NIL)
{
       vc=c[1];sc=c[2];p=poi(sc)matrix vol(vc);
       ...
}

collision vol near

collision vol(id)near

        Treats volumes id collisions between them with the same options as que collision vol vol.

collision vol vol

collision vol(id1)vol(id2)

       Treats volume id1 collisions on the obstacle id2.
Options:
ball: only tests balls are activated (fast but is only suitable for approximately spherical objects.
box: only test boxes are activated (slower, suitable for objects which could determine bounding boxes.
segment: suitable for objects wired (ie reduced to a single facet of connected points).
fac: slower but suitable for any type of object, the default (without option).
dist(d): anticipated collision of d.
coe(f,v_f,r,v_r,c): if yes dynamic is active and if the objects are provided with masses:
       f,v_f = rebound and viscosity force
       r,v_r = rotation force and viscosity
       c = radius multiplier with option ball
       (0,0,0,0,1) by default, .1,-.01,.01,-.01 are good values de bonnes valeurs).
Examples:
ball ball: objects and obstacles are approximately spherical.
segment ball: objects are wired obstacles are approximately spherical.
segment segment: objects and obstacles are wired.
segment fac: objects are wired , obstacles are arbitrary.
etc..

See also:

no collision
yes collision
exec collision vol