From 75f9179c9963ab5d5a5f4b190c780f5455cbd2f3 Mon Sep 17 00:00:00 2001 From: Denis Date: Wed, 18 May 2016 17:45:37 +0300 Subject: [PATCH] Delete 2.c This code wasn't mine. --- lab09/2.c | 53 ----------------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 lab09/2.c diff --git a/lab09/2.c b/lab09/2.c deleted file mode 100644 index 6ef5650..0000000 --- a/lab09/2.c +++ /dev/null @@ -1,53 +0,0 @@ -#include -#include -#include - -#define SIN 0.8660254 - -typedef struct{ - double x, y; -} coordinate; - -// Draws the computation -void draw_koch_snowflake(coordinate a, coordinate b, int t, FILE *f){ - if(!t){ - fprintf(f, "M%f %f L%f %F ", a.x, a.y, b.x, b.y); - return; - } - coordinate tmp = { (b.x - a.x)/3, (b.y - a.y)/3}; - coordinate c = {a.x + tmp.x, a.y + tmp.y}; - coordinate d = {a.x + (1.5 * tmp.x - SIN * tmp.y), a.y + (1.5 * tmp.y + SIN * tmp.x)}; - coordinate e = {a.x + 2 * tmp.x, a.y + 2 * tmp.y}; - draw_koch_snowflake(a, c, t-1, f); - draw_koch_snowflake(c, d, t-1, f); - draw_koch_snowflake(d, e, t-1, f); - draw_koch_snowflake(e, b, t-1, f); -} - -// Provides a frame for the path -void framework(coordinate a, coordinate b, int t, FILE *f){ - fprintf(f, ""); -} - -int main(int argc, char *argv[]){ - int w, h, r; - w = h = 512; - r = w / 3; - int n = atoi(argv[1]); - FILE *f; - if( !(f=fopen("koch.svg","w")) ) return -1; - fprintf(f,"", w, h); - coordinate a = {w / 2, h / 2 + r}; - coordinate b = {w / 2 - r * SIN, h / 2 - r * 0.5}; - coordinate c = {w / 2 + r * SIN, h / 2 - r * 0.5}; - framework(b, a, n, f); - framework(c, b, n, f); - framework(a, c, n, f); - fprintf(f, ""); - fclose(f); - return 0; -}