1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
#include "VonKoch.h"
#include <math.h>
#define PI 3,14159
VonKoch::VonKoch(Punto X, Punto Y){
}
VonKoch::VonKoch(Punto X, Punto Y, float n){
}
VonKoch :: VonKoch(){
a=0;
b;
n;
}
Punto VonKoch::calcolaPunti(float xa,float ya,float xb,float yb){
float xc, yc, xd, yd, xe, ye, segmento;
float beta, alpha;
segmento=sqrt((xb - xa)*(xb - xa)+(yb - ya)*(yb - ya));
printf("\nIl segmento e' lungo: %f", segmento);
xc = xa + 0.33333 * (xb - xa);
yc = ya - 0.33333 * ( yb - ya);
printf("\nxc: %f", xc);
printf("\nyc: %f", yc);
xd = xa + 0.66666 * (xb - xa);
yd = ya - 0.66666 * (yb - ya);
printf("\nxd: %f", xd);
printf("\nyd: %f", yd);
float a = ya-yb;
float b = xb-xa;
alpha = atan2(a,b);
beta = (PI/3) - alpha;
xe = xc + 0.33333 * segmento * cos(beta);
ye = yc + 0.33333 * segmento * sin(beta);
printf("\nxe: %f", xe);
printf("\nye: %f", ye);
Punto A(xa,xb);
}
void VonKoch :: draw(){
if(segmento < n){
drawVonKoch(A,B);
}else{
drawVonKoch(A, C);
drawVonKoch(C, E);
drawVonKoch(E, D);
drawVonKoch(D, B);
}
}
void drawVonKoch(){
//should draw the line between the points
}
|