class Cone{ float r0,r1,d;//les rayons Vecteur pointe, base,dif; float zangle,yangle;// les angles d'Euler de dif public Cone(float r0,float r1){ this.r0= r0 ; this.r1= r1 ; } void initangles( Vecteur lapointe, Vecteur labase){ pointe=lapointe ; base= labase ; pointe.z=rayon*1.5; base.z=rayon*1.5; this.dif=pointe.ajouter(base,-1); d=dif.length(); zangle=atan2(dif.y,dif.x); yangle=atan2(dif.z,sqrt(sq(dif.x)+sq(dif.y))); } public void dessiner(Vecteur b0,Vecteur b1){ initangles(b0,b1); line(b0.x ,b0.y ,rayon ,b1.x ,b1.y ,rayon); pushMatrix(); translate(base.x,base.y,rayon); rotateZ(zangle); rotateY(yangle); fill(185,255,205); noStroke(); float d1=min(200,d); beginShape(QUADS); fill(150,100,50); for(int i=0;i<=12;i++){ float a1=PI/6*i,a2=PI/6*(i+1); vertex(0,r1*cos(a1),r1*sin(a1)); vertex(0,r1*cos(a2),r1*sin(a2)); vertex(d1,r0*cos(a2),r0*sin(a2)); vertex(d1,r0*cos(a1),r0*sin(a1)); } endShape(); popMatrix(); } }