This is a little experiment in using CAD software with a functional representation for solids. I used Mathematica to construct a giant polynomial, and wrote a script which converts arbitrary Mathematica expressions into Antimony's prefix notation.
Last active
September 9, 2016 20:10
-
-
Save antimatter15/2586bc653c503ed30e31bff596563200 to your computer and use it in GitHub Desktop.
Mandelbrot Set for Antimony
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Kevin Kwok 9/9/2016 | |
import fab | |
import math | |
title('Mandelbrot') | |
fn = "+f-2r+q+Y*f2*+Y*f2*XY-+XqXqYq-+Xq-+XqXqYq+Y*f2*XY" | |
fn = "+f-2if10r+q+Y*f2*+Y*f2*+Y*f2*+Y*f2*+Y*f2*+Y*f2*+Y*f2*+Y*f2*+Y*f2*XY-+\ | |
XqXqY-+Xq-+XqXqYq+Y*f2*XY-+Xq-+Xq-+XqXqYq+Y*f2*XYq+Y*f2*+Y*f2*XY-+\ | |
XqXqY-+Xq-+Xq-+Xq-+XqXqYq+Y*f2*XYq+Y*f2*+Y*f2*XY-+XqXqYq+Y*f2*+Y*f2*+\ | |
Y*f2*XY-+XqXqY-+Xq-+XqXqYq+Y*f2*XY-+Xq-+Xq-+Xq-+Xq-+XqXqYq+Y*f2*XYq+Y*\ | |
f2*+Y*f2*XY-+XqXqYq+Y*f2*+Y*f2*+Y*f2*XY-+XqXqY-+Xq-+XqXqYq+Y*f2*XYq+Y*\ | |
f2*+Y*f2*+Y*f2*+Y*f2*XY-+XqXqY-+Xq-+XqXqYq+Y*f2*XY-+Xq-+Xq-+XqXqYq+Y*\ | |
f2*XYq+Y*f2*+Y*f2*XY-+XqXqY-+Xq-+Xq-+Xq-+Xq-+Xq-+XqXqYq+Y*f2*XYq+Y*f2*\ | |
+Y*f2*XY-+XqXqYq+Y*f2*+Y*f2*+Y*f2*XY-+XqXqY-+Xq-+XqXqYq+Y*f2*XYq+Y*f2*\ | |
+Y*f2*+Y*f2*+Y*f2*XY-+XqXqY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xq-+XqXqYq+Y*f2*XYq+Y*f2*+\ | |
Y*f2*XY-+XqXqY" | |
output('shape', fab.shapes.function_prefix_xy(fn, -2, 1, -1.5, 1.5)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* The f-rep syntax accepts four distinct types of atoms.X,Y,and Z \ | |
are replaced | |
by position in the world\[CloseCurlyQuote]s coordinate system at any \ | |
given evaluation point. *) | |
Antimony[x] := "X" | |
Antimony[y] := "Y" | |
Antimony[z] := "Z" | |
(* Table A.1:Unary F-rep functions (pg. 93) *) | |
Antimony[Sin[x_]] := "s" <> Antimony[x] | |
Antimony[Cos[x_]] := "c" <> Antimony[x] | |
Antimony[Tan[x_]] := "t" <> Antimony[x] | |
Antimony[ArcSin[x_]] := "S" <> Antimony[x] | |
Antimony[ArcCos[x_]] := "C" <> Antimony[x] | |
Antimony[ArcTan[x_]] := "T" <> Antimony[x] | |
Antimony[Abs[x_]] := "b" <> Antimony[x] | |
Antimony[Power[x_, 2]] := "q" <> Antimony[x] | |
Antimony[Sqrt[x_]] := "r" <> Antimony[x] | |
Antimony[-x_] := "n" <> Antimony[x] | |
(* Floating point constants are preceded by f, followed by the value \ | |
(e.g.f3.14159 or f6.023e23). *) | |
Antimony[x_Real] := "f" <> ToString[x] | |
Antimony[x_Integer] := "f" <> ToString[x] | |
(*Table A.2:Binary F-rep functions*) | |
Antimony[Times[a_, b__]] := "*" <> Antimony[a] <> Antimony[Times[b]] | |
Antimony[Plus[a_, b__]] := "+" <> Antimony[a] <> Antimony[Plus[b]] | |
Antimony[Power[x_, y_]] := "p" <> Antimony[x] <> Antimony[y] | |
Antimony[Plus[a__, -b_]] := "-" <> Antimony[Plus[a]] <> Antimony[b] | |
Antimony[Times[a_, Power[b_, -1]]] := "/" <> Antimony[a] <> Antimony[b] | |
Antimony[Max[a_, b__]] := "a" <> Antimony[a] <> Antimony[Max[b]] | |
Antimony[Min[a_, b__]] := "i" <> Antimony[a] <> Antimony[Min[b]] | |
Antimony[Min[10, | |
ComplexExpand[Abs[Nest[(#^2 + x + I y) &, x + I y, 9]]]] - 2] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment