File:PuroRotolamentoCirc.gif

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

PuroRotolamentoCirc.gif(240 × 240 pixels, file size: 149 KB, MIME type: image/gif, looped, 159 frames, 1.6 s)

Captions

Captions

Add a one-line explanation of what this file represents

Summary

[edit]
Description
Italiano: Moto di puro rotolamento di un disco su una circonferenza
Date
Source Own work
Author Cielo Francesco

Immagine fatta con processing

Ecco il codice, i parametri sono tutti commentati in modo da renderne facile la modifica per chi volesse. Le impostazioni iniziali sono nella funzione setup.

/* 
 * Moto di puro rotolamento di un disco su una circonferenza
 *
 */

int sz;          // intero che moltiplicato per 16 da la dimensione in
                 // pixel dell'immagine

int R;           // raggio della circonferenza 
int r;           // raggio del disco
float nu;        // frequenza (giri al sec) di rotazione del disco attorno
                 // alla circonferenza
float phi;       // angolo tra il centro del disco e l'asse orizzontale
float theta;     // angolo tra il punto che si vuole osservare sul disco e
                 // l'asse che collega i due centri

int nDent;       // numero di dentini da disegnare sul disco

//variabili per poter calcolare la velocità
float x, y;  
float dx, dy, dt;

void setup()
{
  sz = 15;
  size(16*sz, 16*sz);
  frameRate(20);
  
  R = width/4;
  r = width/16;
  phi = -PI;
  theta = 0;
  nu = 1.0/8;
  
  nDent = 3;
}

void draw() 
{
  background(255);
  
  dt = 1.0/frameRate;   // così la velocità esce in pixel al secondo =P              
  phi = phi + TWO_PI*nu/frameRate;
  theta = PI + (phi*R)/r;
  
  disegnaCirconferenza();
  disegnaDisco();
  
  if((phi >= -HALF_PI) && (phi <= -HALF_PI+TWO_PI))
    saveFrame("img/pr-####.png");

}

void disegnaCirconferenza()
{
  noFill();
  ellipse(width/2, height/2, 2*R, 2*R); //circonferenza
  fill(0);
  ellipse(width/2, height/2, 4, 4);     //centro
  
  // disegno dei dentini
  for(int i = 0; i< nDent*R/r; i++)
  {
    float a = i*TWO_PI/(nDent*R/r);
    float px = 0.98*R*cos(a) + width/2;
    float py = 0.98*R*sin(a) + height/2;
    
    float dentX = 0.9*R*cos(a) + width/2;
    float dentY = 0.9*R*sin(a) + height/2;
    line(dentX, dentY, px, py);
  }
}

void disegnaDisco()
{
  float px, py, tmp;
  float cx, cy;
  float dentX, dentY;
  
  cx = (R + r)*cos(phi);
  cy = (R + r)*sin(phi);
  
  tmp = r*cos(theta) + (R + r);
  py = r*sin(theta);
  px = cos(phi)*tmp - sin(phi)*py;
  py = sin(phi)*tmp + cos(phi)*py;
  
  // calcolo del vettore velocità (divisa per due per farcela stare
  // nell'immagine anche quando è abbastanza grande)
  dx = (px - x)/dt/2; dy = (py - y)/dt/2;
  x = px; y = py;
  
  cx = width/2 + cx; cy = height/2 + cy;
  px = width/2 + px; py = height/2 + py;
  
  // disco
  fill(230);
  ellipse(cx, cy, 2*r, 2*r);
  fill(0);
  ellipse(cx, cy, 4, 4);
  
  // punto di contatto
  fill(0, 0, 255);
  ellipse(R*cos(phi) + width/2, R*sin(phi) + height/2, 4, 4);
  
  // punto da osservare
  fill(255, 0, 0);
  ellipse(px, py, 4, 4);
  line(cx, cy, px, py);
  
  //velocità
  stroke(255, 0, 0);
  line(px, py, px+dx, py+dy);
  stroke(0);
  
  // disegno dei dentini
  for(int i = 0; i<nDent; i++)
  {
    float a = i*TWO_PI/nDent + theta;
    tmp = 0.9*r*cos(a) + (R + r);
    py = 0.9*r*sin(a);
    px = cos(phi)*tmp - sin(phi)*py;
    py = sin(phi)*tmp + cos(phi)*py; 
    
    tmp = 0.8*r*cos(a) + (R + r);
    dentY = 0.8*r*sin(a);
    dentX = cos(phi)*tmp - sin(phi)*dentY;
    dentY = sin(phi)*tmp + cos(phi)*dentY;
    line(dentX + width/2, dentY + height/2, 
         px    + width/2, py    + height/2);
  }
  
}

Licensing

[edit]
I, the copyright holder of this work, hereby publish it under the following license:
GNU head Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
This licensing tag was added to this file as part of the GFDL licensing update.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current21:07, 27 November 2008Thumbnail for version as of 21:07, 27 November 2008240 × 240 (149 KB)Skyhc (talk | contribs){{Informazioni file |Descrizione = Moto di puro rotolamento di un disco su una circonferenza |Autore = Cielo Francesco }}

There are no pages that use this file.

File usage on other wikis

The following other wikis use this file:

Metadata