Page 1 sur 1
accel et radius
Posté : dim. 25 nov. 2012, 19:25
par zariski
Il me semble que ma demande précédente sur un autre post est passée inaperçue, aussi je la réitère :
SVP Que donnent : pair accel(path p, int t, int sign=0); et real radius(path p, real t); ?
Perso j'ai compris que le premier donnait un vecteur accélération alors que le second donnait un rayon de courbure.
Problème, j'obtiens des trucs farfelus ....
Re: accel et radius
Posté : dim. 25 nov. 2012, 19:38
par GM
zariski a écrit :Problème, j'obtiens des trucs farfelus ....
Par rapport à ??
De la lecture sur la notion d'accélération :
http://www.vsmp.ch/crm/Articles_bul/B94_MYB.pdfet deux traces de choses que j'ai cru comprendre :
http://docs.gmaths.net/tempo/courbe_bezier.pdf
*** Pour masquer/découvrir le code Asymptote qui a permis de créer la figure, il faut cliquer dessus. ;-) ***
- CODE ASYMPTOTE de la figure ci-dessus :
Tout sélectionner
// Fonction accel
// Syntaxe 1 : pair accel(path p, int t, int sign=0);
// If sign < 0, return the acceleration of the incoming path p at node t ;
// if sign > 0, return the acceleration of the outgoing path.
// if sign=0, the mean of these two accelerations is returned.
// Syntaxe 2 : pair accel(path p, real t);
// returns the acceleration of the path p at the point t.
import geometry;
size(10cm,0);
path p=(-5,0)..(10,0)..(10,10)..(0,20)..(-10,20)..(-5,15)..cycle;
draw("p",p); dot(p,2bp+black);
pair po, pa;
for(real k=0; k<length(p); k+=.05)
{
po=point(p,k);
pa = po+(accel(p,k))/6;
draw(po--pa,red);
}
void acceleration(path p, int k, real t){
pair z0=point(p,k),
c0=postcontrol(p,k),
z1=point(p,k+1),
c1=precontrol(p,k+1),
m0=(1-t)*z0+t*c0,
m1=(1-t)*c0+t*c1,
m2=(1-t)*c1+t*z1,
m3=(1-t)*m0+t*m1,
m4=(1-t)*m1+t*m2,
z2=(1-t)*m3+t*m4;
path CourbeBezier = z0 .. controls c0 and c1 .. z1;
draw(CourbeBezier,1bp+blue);
path lignebrisee = z0 -- c0 -- c1 -- z1;
draw(lignebrisee^^m0--m1--m2^^m3--m4,linetype("4 4"));
dot(z0^^z1^^z2,blue); dot(c0^^c1,gray);
dot(m0--m1--m2^^m3--m4,green);
draw(z2--(z2+accel(CourbeBezier,t)/6),.8bp+.5green,Arrow());
write((precontrol(p,k)+postcontrol(p,k))/2-point(p,k));
}
acceleration(p,1,.75);
acceleration(p,3,.75);
acceleration(p,5,.75);
addMargins(2mm,2mm);
Un sujet de discussion où il a été question de la fonction accel :
http://sourceforge.net/projects/asympto ... ic/4782302 où il a été donné
- un lien vers les définitions d'accel :
Code : Tout sélectionner
286 pair accel(Int t, Int sign) const {
287 if(sign == 0) return 0.5*(preaccel(t)+postaccel(t));
288 if(sign > 0) return postaccel(t);
289 return preaccel(t);
290 }
291
292 pair accel(double t) const {
293 if(!cycles) {
294 if(t <= 0) return postaccel((Int) 0);
295 if(t >= n-1) return preaccel(n-1);
296 }
297 Int i=Floor(t);
298 t -= i;
299 if(t == 0) return 0.5*(postaccel(i)+preaccel(i));
300 pair z0=point(i);
301 pair c0=postcontrol(i);
302 pair c1=precontrol(i+1);
303 pair z1=point(i+1);
304 return 6.0*t*(z1-z0+3.0*(c0-c1))+6.0*(z0+c1)-12.0*c0;
305 }
- une réponse (dernier message) à une question que je me posais.
Je ne pourrai pas mieux expliquer... et je n'ai surtout pas de temps en ce moment, pour proposer mieux.
Re: accel et radius
Posté : dim. 25 nov. 2012, 19:53
par zariski
merci pour la réponse...
Je ne pense pas utiliser ces notions tous les jours, aussi je m'en passerai certainement volontiers !
Bonne soirée !