38 lines
912 B
Text
38 lines
912 B
Text
import <Utilities/Math.sl>;
|
|
import <Utilities/Conversion.sl>;
|
|
|
|
initPoints := [[0,0],[1,0]];
|
|
|
|
f1(point(1)) :=
|
|
let
|
|
matrix := [[cos(45 * (pi/180)), -sin(45 * (pi/180))],
|
|
[sin(45 * (pi/180)), cos(45 * (pi/180))]];
|
|
in
|
|
head(transpose((1/sqrt(2)) * matmul(matrix, transpose([point]))));
|
|
|
|
f2(point(1)) :=
|
|
let
|
|
matrix := [[cos(135 * (pi/180)), -sin(135 * (pi/180))],
|
|
[sin(135 * (pi/180)), cos(135 * (pi/180))]];
|
|
in
|
|
head(transpose((1/sqrt(2)) * matmul(matrix, transpose([point])))) + initPoints[2];
|
|
|
|
matmul(X(2),Y(2))[i,j] := sum(X[i,all]*Y[all,j]);
|
|
|
|
entry(steps(0), maxX(0), maxY(0)) :=
|
|
let
|
|
scaleX := maxX / 1.5;
|
|
scaleY := maxY;
|
|
|
|
shiftX := maxX / 3.0 / 1.5;
|
|
shiftY := maxY / 3.0;
|
|
in
|
|
round(run(steps, initPoints) * [scaleX, scaleY] + [shiftX, shiftY]);
|
|
|
|
run(steps(0), result(2)) :=
|
|
let
|
|
next := f1(result) ++ f2(result);
|
|
in
|
|
result when steps <= 0
|
|
else
|
|
run(steps - 1, next);
|