Geometria-funktiot (Kirjasto sopii iPAD:lle)

Tämä kirjasto sisältää seuraavat komennot
  • Ellipsi
  • Jana
  • Janan keskinormaali
  • Janan keskipiste
  • Jänne
  • Kaari
  • Koordinaatisto
  • Kolmio
  • Kommentti
  • Kulma
  • Monikulmio
  • Mittaa-funktiot
  • Nelikulmio
  • Neliö
  • Piirtokolmio
  • Piste
  • Puolisuunnikas
  • Segmentti
  • Sektori
  • Suorakulmio
  • Suunnikas
  • Tangentti
  • Tähti
  • Viivoitin
  • Ympyrä

// Ohjelman tehnyt e-Oppi Oy, Geometria kirjasto iPAD:lle
// Viimeksi päivitetty: 31.8.2017
// Oletus täyttöväri
int R =250; // Oletus punainen
int G = 200; // Oletus vihreä
int B = 0; // Oletus sininen
int A = 100; // Oletus läpinäkyvyys

void setup () {
     size(601,601); // Älä muuta ikkunan kokoa
}
// Kaikki komennot laitetaan void draw ()-lohkoon
void draw () {
      koordinaatisto();
    // Kirjoita tähän kaikki komennot
}

// Tästä alkaa funktiot eli aliohjelmat
// Älä tee näihin muutoksia !!

// Koordinaatisto on suunniteltu 600x600 ikkunaan
void koordinaatisto() {
     fill(255);
     noStroke();
     rect(0,0,600,600);
     stroke(128);
     strokeWeight(1);
     for (int z = 0; z < 21; z++) {
         line(z*30,0,z*30,600); 
         line(0,0+z*30,600,z*30); 
     }
     strokeWeight(3);
     stroke(0,0,100);
     line(300,3,300,600);
     line(0,300,600,300);
     fill(0,0,100);
     triangle(590,290,598,300,590,310);
     triangle(300,3,310,10,290,10);
     text("x",580,285);
     text("y",315,20);
     textSize(20);
     text("1",323,320);
     text("1",280,280);
     translate(300,300);
     scale(1,-1);
     strokeWeight(2); // Oletus paksuus
     fill(R,G,B,A); // Oletusväri
     stroke(0);
}

void suorakulmio(float x, float y, float leveys, float korkeus) {
     float x2 = map(x,-10,10,-300,300);
     float y2 = map(y,-10,10,-300,300);
     float leveys2 = map(leveys,-10,10,-300,300);
     float korkeus2 = map(korkeus,-10,10,-300,300);
     rect(x2,y2,leveys2,korkeus2);
}
void nelio(float x, float y, float sivu) {
     float x2 = map(x,-10,10,-300,300);
     float y2 = map(y,-10,10,-300,300);
     float sivu2 = map(sivu,-10,10,-300,300);
     rect(x2,y2,sivu2,sivu2);
}
void ympyra(float x, float y, float sade) {
     float x2 = map(x,-10,10,-300,300);
     float y2 = map(y,-10,10,-300,300);
     float sade2 = map(sade,-10,10,-300,300);
     ellipse(x2,y2,2*sade2,2*sade2);
     point(x2,y2);
}
void ellipsi(float x, float y, float leveys, float korkeus) {
     float x2 = map(x,-10,10,-300,300);
     float y2 = map(y,-10,10,-300,300);
     float leveys2 = map(leveys,-10,10,-300,300);
     float korkeus2 = map(korkeus,-10,10,-300,300);
     ellipse(x2,y2,leveys2,korkeus2);
     point(x2,y2);
}
void piste(float x, float y) {
     float x2 = map(x,-10,10,-300,300);
     float y2 = map(y,-10,10,-300,300);
     strokeWeight(3);
     // fill(255,0,0);
     ellipse(x2,y2,10,10);
     fill(R,G,B,A);
     strokeWeight(2);
     stroke(0);
}
void jana(float x1, float y1, float x2, float y2) {
     float x12 = map(x1,-10,10,-300,300);
     float y12 = map(y1,-10,10,-300,300);
     float x22 = map(x2,-10,10,-300,300);
     float y22 = map(y2,-10,10,-300,300);
        strokeWeight(3);
     // fill(255,0,0);
     line(x12,y12,x22,y22);
     ellipse(x12,y12,10,10);
     ellipse(x22,y22,10,10);
      fill(R,G,B,A);
     strokeWeight(2);
     stroke(0);
}
void keskipiste(float x1, float y1, float x2, float y2) {
     float x12 = map(x1,-10,10,-300,300);
     float y12 = map(y1,-10,10,-300,300);
     float x22 = map(x2,-10,10,-300,300);
     float y22 = map(y2,-10,10,-300,300);
     float z1 = (x1+x2)/2;
     float z2 = (y1+y2)/2;
        strokeWeight(3);
     // fill(255,0,0);
     line(x12,y12,x22,y22);
     ellipse(x12,y12,10,10);
     ellipse(x22,y22,10,10);
     fill(255,0,0);
     ellipse(z1*30,z2*30,10,10);
      fill(R,G,B,A);
     strokeWeight(2);
     stroke(0);
}
void normaali(float x1, float y1, float x2, float y2) {
     float x12 = map(x1,-10,10,-300,300);
     float y12 = map(y1,-10,10,-300,300);
     float x22 = map(x2,-10,10,-300,300);
     float y22 = map(y2,-10,10,-300,300);
       strokeWeight(3);
    // fill(255,0,0);
     line(x12,y12,x22,y22);
     float x0 = (x1+x2)/2;
     float y0 = (y1+y2)/2;
     float k = ((y22-y12)/(x22-x12));
     if (y1 == y2) {
       line(x0*30,300,x0*30,-300);
     }
     for (int s=-3000; s<3000; s++) {
          float y = (-1/k)*(s/10.0)+((1/k)*x0+y0)*30;
          ellipse((s/10.0),y,1,1);
     }
     ellipse(x12,y12,10,10);
     ellipse(x22,y22,10,10);
     fill(R,G,B,A);
     strokeWeight(2);
     stroke(0);
}
void sektori(float x, float y, float sade, float kulma1, float kulma2) {
     float x2 = map(x,-10,10,-300,300);
     float y2 = map(y,-10,10,-300,300);
     float sade2 = map(sade,-10,10,-300,300);
      if (kulma2 < kulma1) {
       float muuta = kulma1;
       kulma1 = kulma2;
       kulma2 = muuta;
     }
      arc(x2,y2,2*sade2,2*sade2,radians(kulma1),radians(kulma2),PIE);
     point(x2,y2);
}
void kaari(float x, float y, float sade, float kulma1, float kulma2) {
     float x2 = map(x,-10,10,-300,300);
     float y2 = map(y,-10,10,-300,300);
     float sade2 = map(sade,-10,10,-300,300);
     noFill();
      if (kulma2 < kulma1) {
       float muuta = kulma1;
       kulma1 = kulma2;
       kulma2 = muuta;
     }
      arc(x2,y2,2*sade2,2*sade2,radians(kulma1),radians(kulma2));
     point(x2,y2);
       fill(R,G,B,A); // Oletusväri
}
void janne(float x, float y, float sade, float kulma1, float kulma2) {
     float x2 = map(x,-10,10,-300,300);
     float y2 = map(y,-10,10,-300,300);
     float sade2 = map(sade,-10,10,-300,300);
     float rx1 = sade2*cos(radians(kulma1));
     float ry1 = sade2*sin(radians(kulma1));
     float rx2 = sade2*cos(radians(kulma2));
     float ry2 = sade2*sin(radians(kulma2));
     line(x2+rx1,y2+ry1,x2+rx2,y2+ry2);
     point(x2,y2);
}
void segmentti(float x, float y, float sade, float kulma1, float kulma2) {
     float x2 = map(x,-10,10,-300,300);
     float y2 = map(y,-10,10,-300,300);
     float sade2 = map(sade,-10,10,-300,300);
      if (kulma2 < kulma1) {
       float muuta = kulma1;
       kulma1 = kulma2;
       kulma2 = muuta;
     }
       arc(x2,y2,2*sade2,2*sade2,radians(kulma1),radians(kulma2),CHORD);
     point(x2,y2);
}
void suunnikas(float x, float y, float sivu1, float sivu2, float kulma) {
     float x2 = map(x,-10,10,-300,300);
     float y2 = map(y,-10,10,-300,300);
     float sivu12 = map(sivu1,-10,10,-300,300);
     float sivu22 = map(sivu2,-10,10,-300,300);
     quad(x2,y2, x2+sivu12,y2, x2+sivu12+sivu22*cos(radians(kulma)),y2+sivu22*sin(radians(kulma)), x2+sivu22*cos(radians(kulma)),y2+sivu22*sin(radians(kulma)) );
}
void puolisuunnikas(float x, float y, float a, float b, float h, float dx) {
     float x2 = map(x,-10,10,-300,300);
     float y2 = map(y,-10,10,-300,300);
     float a2 = map(a,-10,10,-300,300);
     float b2 = map(b,-10,10,-300,300);
     float h2 = map(h,-10,10,-300,300);
     float dx2 = map(dx,-10,10,-300,300);
     quad(x2,y2,x2+b2,y2,x2+a2+dx2,y2+h2,x2+dx2,y2+h2);
}
void kolmio(float x, float y, float sivu1, float sivu2, float kulma) {
     float x2 = map(x,-10,10,-300,300);
     float y2 = map(y,-10,10,-300,300);
     float sivu12 = map(sivu1,-10,10,-300,300);
     float sivu22 = map(sivu2,-10,10,-300,300);
     triangle(x2,y2, x2+sivu12,y2, x2+sivu22*cos(radians(kulma)),y2+sivu22*sin(radians(kulma)) );
}
void kolmiokanta(float x1, float y1, float sivu, float kulma1, float kulma2) {
     float x2 = map(x1,-10,10,-300,300);
     float y2 = map(y1,-10,10,-300,300);
     float sivu2 = map(sivu,-10,10,-300,300);
     float a = (sin(radians(kulma2))*sivu)/sin(radians(180-(kulma1+kulma2)));
     float x0 = x2+30*a*cos(radians(kulma1));
     float y0 = y2+30*a*sin(radians(kulma1));
     triangle(x2,y2,x2+sivu2,y2,x0,y0);
     
}
void nelikulmio(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) {
     float x12 = map(x1,-10,10,-300,300);
     float y12 = map(y1,-10,10,-300,300);
     float x22 = map(x2,-10,10,-300,300);
     float y22 = map(y2,-10,10,-300,300);
     float x32 = map(x3,-10,10,-300,300);
     float y32 = map(y3,-10,10,-300,300);
     float x42 = map(x4,-10,10,-300,300);
     float y42 = map(y4,-10,10,-300,300);
     quad(x12,y12,x22,y22,x32,y32,x42,y42);
}
void kolmioXY(float x1, float y1, float x2, float y2, float x3, float y3) {
     float x12 = map(x1,-10,10,-300,300);
     float y12 = map(y1,-10,10,-300,300);
     float x22 = map(x2,-10,10,-300,300);
     float y22 = map(y2,-10,10,-300,300);
     float x32 = map(x3,-10,10,-300,300);
     float y32 = map(y3,-10,10,-300,300);
     triangle(x12,y12,x22,y22,x32,y32);
}
void kulma(float x, float y, float sivu1, float sivu2, float kulma1, float kulma2) {
     float x2 = map(x,-10,10,-300,300);
     float y2 = map(y,-10,10,-300,300);
     float sivu12 = map(sivu1,-10,10,-300,300);
     float sivu22 = map(sivu2,-10,10,-300,300);
     arc(x2,y2,30,30,radians(kulma1),radians(kulma1+kulma2),PIE);
     line(x2,y2,x2+sivu12*cos(radians(kulma1)),y2+sivu12*sin(radians(kulma1)));
     line(x2,y2,x2+sivu22*cos(radians(kulma1+kulma2)),y2+sivu22*sin(radians(kulma1+kulma2)));
}


void monikulmio(float x, float y, float sade, float lukumaara, float alkukulma) {
     if (lukumaara > 0) {
     float x2 = map(x,-10,10,-300,300);
     float y2 = map(y,-10,10,-300,300);
     if (lukumaara == 1) {
          ellipse(x2,y2,5,5);
     } else {
          float lisays = 360.0/lukumaara;
          float kulma = alkukulma+lisays;
          beginShape();
             for (int s = 0; s<=lukumaara; s++) {
                 float x1 = sade*30*cos(radians(kulma));
                 float y1 = sade*30*sin(radians(kulma));
                 vertex(x2+x1,y2+y1);
                 kulma = kulma+lisays;
             }
          endShape();
          }
     }
}


void tangentti(float x, float y, float sade,float kulma) {
      float x2 = map(x,-10,10,-300,300);
      float y2 = map(y,-10,10,-300,300);
      float sade2 = map(sade,-10,10,-300,300);
      noFill();
      ellipse(x2,y2,2*sade2,2*sade2);
      float rx2 = sade2*cos(radians(kulma));
      float ry2 = sade2*sin(radians(kulma));
      float x0 = x+sade*cos(radians(kulma));
      float y0 = y+sade*sin(radians(kulma));
      line(x2,y2,x2+rx2,y2+ry2);
      point(x2,y2);
      float k = (y0-y)/(x0-x);
      if (kulma%180 == 0) {
         line(x0*30,300,x0*30,-300);
      }
      
      for (int s=-30000; s<30000; s++) {
           float y22 = (-1/k)*(s/100.0)+((1/k)*x0+y0)*30;
           ellipse((s/100.0),y22,1,1);
      }
        fill(R,G,B,A); // Oletusväri
}
void kommentti(String teksti,float x,float y,float koko) {
      float x2 = map(x,-10,10,-300,300);
      float y2 = map(y,-10,10,-300,300);
      fill(0);
      pushMatrix();
      scale(1,-1);
      fill(0);
      textSize(koko);
      text(teksti,x2,-y2);
      popMatrix();
      textSize(20);
        fill(R,G,B,A); // Oletusväri
}

void mittaakulma(float x1, float y1, float x2, float y2, float x3, float y3) {
float xx1 = map(x1,-10,10,-300,300);
float yy1 = map(y1,-10,10,-300,300);
float xx2 = map(x2,-10,10,-300,300);
float yy2 = map(y2,-10,10,-300,300);
float xx3 = map(x3,-10,10,-300,300);
float yy3 = map(y3,-10,10,-300,300);
float sade1 = sqrt((y1-y2)*(y1-y2)+(x1-x2)*(x1-x2));
float sade2 = sqrt((y3-y2)*(y3-y2)+(x3-x2)*(x3-x2));
float kulma1 = acos(abs(x1-x2)/sade1);
float kulma2 = acos(abs(x3-x2)/sade2);
float summa1 = 0;
float summa2 = 0;
float lisays = 0;
if ( ((y1-y2) == 0) && (x1 >= x2) ) { summa1 = 0; }
if ( ((y2-y1) == 0) && (x2 > x1) ) { summa1 = 180; }
if ( ((x1-x2) == 0) && (y1 >= y2) ) { summa1 = 90; }
if ( ((x2-x1) == 0) && (y2 > y1) ) { summa1 = 270; }

if (abs(x3-x2) == 0) {
lisays = 90-degrees(kulma1);
}

if ( ((x1-x2) > 0) && ((y1 -y2) > 0) ) {
summa1 = degrees(kulma1);
}
if ( ((x1-x2) < 0) && ((y1 -y2) > 0) ) {
summa1 = (90-degrees(kulma1))+90;
}
if ( ((x1-x2) < 0) && ((y1 -y2) < 0) ) {
summa1 = degrees(kulma1)+180;
}
if ( ((x1-x2) >=0) && ((y1 -y2) < 0) ) {
summa1 = 360-degrees(kulma1);
}

if ( ((x3-x2) > 0) && ((y3 -y2) > 0) ) {
summa2 = degrees(kulma2);
if ((summa1 >= 0) && (summa1 < 90)) {
if (summa2 > summa1) {
lisays = summa2-summa1;
} else {
lisays = 360-summa1+summa2;
}
}
if ((summa1 >= 90) && (summa1 < 180)) {
lisays = 360-summa1+summa2;
}
if ((summa1 >= 180) && (summa1 < 270)) {
lisays = 360-summa1+summa2;
}
if ((summa1 >= 270) && (summa1 < 360)) {
lisays = 360-summa1+summa2;
}
}
if ( ((x3-x2) <= 0) && ((y3 -y2) >= 0) ) {
summa2 = (90-degrees(kulma2))+90;
if ((summa1 >= 0) && (summa1 < 90)) {
lisays = summa2-summa1;
}
if ((summa1 >= 90) && (summa1 < 180)) {
if (summa2 > summa1) {
lisays = summa2-summa1;
} else {
lisays = 360-summa1+summa2;
}
}
if ((summa1 >= 180) && (summa1 < 270)) {
lisays = 360-summa1+summa2;
}
if ((summa1 >= 270) && (summa1 < 360)) {
lisays = 360-summa1+summa2;
}
}
if ( ((x3-x2) <= 0) && ((y3 -y2) <= 0) ) {
summa2 = degrees(kulma2)+180;
if ((summa1 >= 0) && (summa1 < 90)) {
lisays = summa2-summa1;
}
if ((summa1 >= 90) && (summa1 < 180)) {
lisays = summa2-summa1;
}
if ((summa1 >= 180) && (summa1 < 270)) {

if (summa2 > summa1) {
lisays = summa2-summa1;
} else {
lisays = 360-summa1+summa2;
}
}
if ((summa1 >= 270) && (summa1 < 360)) {
lisays = 360-summa1+summa2;
}
}
if ( ((x3-x2) >= 0) && ((y3 -y2) <= 0) ) {
summa2 = 360-degrees(kulma2);
if ((summa1 >= 0) && (summa1 < 90)) {
lisays = summa2-summa1;
}
if ((summa1 >= 90) && (summa1 < 180)) {
lisays = summa2-summa1;
}
if ((summa1 >= 180) && (summa1 < 270)) {
lisays = summa2-summa1;

}
if ((summa1 >= 270) && (summa1 < 360)) {
if (summa2 > summa1) {
lisays = summa2-summa1;
} else {
lisays = 360-summa1+summa2;
}
}

}

float summa3 = (summa1+summa1+lisays)/2;
strokeWeight(6);
point(xx1,yy1);
point(xx2,yy2);
point(xx3,yy3);
strokeWeight(3);
line(xx2,yy2,xx1,yy1);
line(xx2,yy2,xx3,yy3);
noFill();
arc(xx2,yy2,35,35,radians(summa1),radians(summa1+lisays),PIE);
float ds = 20*(sade1 + sade2)/2;
float dx = ds*cos(radians(summa3));
float dy = ds*sin(radians(summa3));
fill(0);
pushMatrix();
scale(1,-1);
fill(255,0,0);
text(""+nfc(lisays,1)+"\u00B0",xx2+dx/2,-(yy2+dy/2));
popMatrix();
strokeWeight(2);
fill(R,G,B,A);
}
void mittaajana(float x1, float y1, float x2, float y2) { float x12 = map(x1,-10,10,-300,300); float y12 = map(y1,-10,10,-300,300); float x22 = map(x2,-10,10,-300,300); float y22 = map(y2,-10,10,-300,300); float x0 = (x12+x22)/2; float y0 = (y12+y22)/2; float pituus = sqrt((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1)); strokeWeight(5); line(x12,y12,x22,y22); strokeWeight(10); point(x12,y12); point(x22,y22); pushMatrix(); scale(1,-1); fill(255,0,0); text(""+round(10*pituus)/10.0,x0+20,-y0+20); popMatrix(); fill(R,G,B,A); strokeWeight(2); stroke(0); } void mittaasuora(float x1, float y1,float k, float b) { float x12 = map(x1,-10,10,-300,300); float y12 = map(y1,-10,10,-300,300); float b2 = map(b,-10,10,-300,300); float x2 = -300; float y2 = k*x2+b2; float pituus = sqrt((y2-y12)*(y2-y12)+(x2-x12)*(x2-x12)); float x0 = 0; float y0 = 0; for (int s=-3000; s<3000; s++) { float y =k*(s/10.0)+b2; ellipse((s/10.0),y,1,1); float y3 = k*(s/10.0)+b2; float pituus3 = sqrt((y3-y12)*(y3-y12)+((s/10.0)-x12)*((s/10.0)-x12)); if (pituus3 < pituus) { pituus = pituus3; x0 = (s/10); y0 = y3; } } strokeWeight(8); point(x12,y12); point(x0,y0); strokeWeight(3); line(x12,y12,x0,y0); fill(0); pushMatrix(); scale(1,-1); fill(255,0,0); text(""+round(10*(pituus/30.0))/10.0,(x0+x12)/2.0+10,-((y0+y12)/2.0)+25); popMatrix(); strokeWeight(2); fill(R,G,B,A); } void mittaakaari(float x, float y, float sade, float kulma1, float kulma2) { float x2 = map(x,-10,10,-300,300); float y2 = map(y,-10,10,-300,300); float sade2 = map(sade,-10,10,-300,300); noFill(); if (kulma2 < kulma1) { float muuta = kulma1; kulma1 = kulma2; kulma2 = muuta; } arc(x2,y2,2*sade2,2*sade2,radians(kulma1),radians(kulma2)); point(x2,y2); fill(250,200,0,150); // Oletusväri float pituus = ((kulma2-kulma1)/360)*2*PI*sade; float dx = 35*sade*cos(radians((kulma2+kulma1)/2.0)); float dy = 35*sade*sin(radians((kulma2+kulma1)/2.0)); pushMatrix(); scale(1,-1); fill(255,0,0); text(""+round(10*pituus)/10.0,x2+dx,-(y2+dy)); popMatrix(); strokeWeight(2); fill(R,G,B,A); } void mittaahypotenuusa(float x, float y, float a, float b) { float x2 = map(x,-10,10,-300,300); float y2 = map(y,-10,10,-300,300); float a2 = map(a,-10,10,-300,300); float b2 = map(b,-10,10,-300,300); triangle(x2,y2,x2+a2,y2,x2,y2+b2); float pituus = sqrt(a*a+b*b); pushMatrix(); scale(1,-1); fill(255,0,0); text(""+round(10*pituus)/10.0,(x2+(x2+a2))/2,-(y2+(y2+b2))/2); popMatrix(); strokeWeight(2); fill(R,G,B,A); } void mittaakateetti(float x, float y, float a, float c) { float x2 = map(x,-10,10,-300,300); float y2 = map(y,-10,10,-300,300); float a2 = map(a,-10,10,-300,300); float b = sqrt(c*c-a*a); float b2 = map(b,-10,10,-300,300); triangle(x2,y2,x2+a2,y2,x2,y2+b2); float pituus = sqrt(c*c-a*a); pushMatrix(); scale(1,-1); fill(255,0,0); text(""+round(10*pituus)/10.0,x2-35,-(y2+(y2+b2))/2); popMatrix(); strokeWeight(2); fill(R,G,B,A); } void tahti(float x, float y, float sade1, float sade2, float lukumaara, float alkukulma) { if (lukumaara > 0) { float x2 = map(x,-10,10,-300,300); float y2 = map(y,-10,10,-300,300); if (lukumaara == 1) { ellipse(x2,y2,5,5); } else { float lisays = 360.0/lukumaara; float kulma = alkukulma+lisays; beginShape(); for (int s = 0; s<=lukumaara; s++) { float x1 = sade1*30*cos(radians(kulma)); float y1 = sade1*30*sin(radians(kulma)); vertex(x2+x1,y2+y1); float x12 = sade2*30*cos(radians(kulma+lisays/2)); float y12 = sade2*30*sin(radians(kulma+lisays/2)); vertex(x2+x12,y2+y12); kulma = kulma+lisays; } endShape(); } } } void piirtokolmio(float x, float y, float kulma) { fill(0,100,255,100); noStroke(); float h = 150; float x2 = map(x,-10,10,-300,300); float y2 = map(y,-10,10,-300,300); pushMatrix(); translate(x2,y2); rotate(radians(kulma)); triangle(-h,0,h,0,0,h); fill(0); ellipse(0,0,5,5); for (int s = 0; s <= 180; s = s + 10) { float a1 = 100*cos(radians(s)); float b1 = 100*sin(radians(s)); float a2 = 50*cos(radians(s)); float b2 = 50*sin(radians(s)); stroke(0,0,255); strokeWeight(1); line(a1,b1,a2,b2); } for (int s = 0; s <= 180; s = s + 5) { float a1 = 100*cos(radians(s)); float b1 = 100*sin(radians(s)); float a2 = 90*cos(radians(s)); float b2 = 90*sin(radians(s)); stroke(0); strokeWeight(1); line(a1,b1,a2,b2); } for (int s = 0; s <= 180; s = s + 45) { float a1 = 100*cos(radians(s)); float b1 = 100*sin(radians(s)); float a2 = 20*cos(radians(s)); float b2 = 20*sin(radians(s)); stroke(255,0,0); strokeWeight(1); line(a1,b1,a2,b2); } popMatrix(); stroke(0); fill(R,G,B,A); strokeWeight(2); // Oletus paksuus } void viivoitin(float x, float y, float kulma) { fill(100,255,100,100); noStroke(); float x2 = map(x,-10,10,-300,300); float y2 = map(y,-10,10,-300,300); pushMatrix(); translate(x2,y2); rotate(radians(kulma)); rect(0,0,300,30); fill(0); ellipse(0,0,5,5); for (int s=0; s <= 20; s=s+1) { stroke(0); strokeWeight(1); line(s*15,0,s*15,10); } for (int s=0; s <= 10; s=s+1) { stroke(0,0,255); strokeWeight(1); line(s*30,0,s*30,20); } for (int s=0; s <= 100; s=s+1) { stroke(255,0,255); strokeWeight(1); line(s*3,0,s*3,5); } popMatrix(); stroke(0); fill(R,G,B,A); strokeWeight(2); // Oletus paksuus }