Drepanoide

Drepanoide: a forma di falce, in greco.
La sua area è equiestesa a quella del parallelogramma OAA’O’.

  • Mouse (posizione orizzontale): cambia la figura
  • Mouse (tasto): rivela la proprietà
  • Applicazione Java
color fSfondo, 
      fPrimo, 
      fSecondo,
      sPrimo, 
      sSecondo,
      cLettere;   

int   dx, dy; 
float CCx, CCy, CC1x, Ax, Ay, CC2x, A1x, CC3x, CCr, CCd;

PFont fontLettere;

void setup()
{
   size(500, 350); 
   ellipseMode(CENTER_RADIUS); 
   smooth(); 
   fontLettere=loadFont("C16.vlw"); 
   textFont(fontLettere);
   textAlign(CENTER);

   fSfondo =color(255, 255, 255);
   fPrimo  =color(0, 0, 0);         
   sPrimo  =color(0);
   fSecondo=color(0, 255, 0, 50); 
   sSecondo=color(0, 255, 0);  
   cLettere=color(0, 0, 255);       
   		 
   dx=width; 
   dy=height;
   CCd=dx*0.40; 
   CCr=CCd/2;
   CCx=dx/2; 
   CCy=dy*0.66; 
   CC1x=CCx-CCr; 
   CC2x=CCx+CCr;    
  
   noLoop();
}

void mousePressed() { redraw(); }
void mouseMoved()  { redraw(); }
void mouseDragged() { redraw(); }

void draw()
{
  aggiorna();
  background(fSfondo); 
  smooth();  
  noStroke();
  
  fill(fPrimo);   
    ellipse(CC3x, Ay, CCr, CCr);
  stroke(fSfondo);
    strokeWeight(2);                                    
    fill(fSfondo);  
    ellipse(CC1x, CCy, CCr, CCr);                                    
    ellipse(CC2x, CCy, CCr, CCr);
									
  if(mousePressed)
  {  
    strokeWeight(1);                                         
      stroke(sSecondo); 
      fill(fSfondo);  
      ellipse(CC1x, CCy, CCr, CCr);                                    
      ellipse(CC2x, CCy, CCr, CCr);
    strokeWeight(2);                                    
      stroke(sSecondo); 
      fill(fSecondo); 
      quad(Ax, Ay, A1x, Ay, CC2x, CCy, CC1x, CCy);
    stroke(cLettere); 
      fill(cLettere); 
      ellipse(CC1x, CCy, 2, 2);                   
      ellipse(CC2x, CCy, 2, 2);
      ellipse(Ax  , Ay , 2, 2);                   
      ellipse(A1x , Ay , 2, 2);
      text("O" , CC1x  , CCy+20);              
      text("O'", CC2x  , CCy+20);
      text("A" , Ax -20, Ay-20);
      text("A'", A1x+20, Ay-20);
  }
}

void aggiorna()
{
   Ax=constrain(mouseX, CCx-CCr, CCx+CCr)-CCr;
   A1x=Ax+CCd;
   Ay=CCy-CCr*sin(acos((CC1x-Ax)/CCr));
   CC3x=Ax+CCr;
}