Last active
August 23, 2020 07:47
-
-
Save globalcitizen/ded2ba77b48f75f2813f156c84246e24 to your computer and use it in GitHub Desktop.
Angelscript simplification concept
This file contains hidden or 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
// AngelCAD code. | |
pos3d@ p(double x, double y, double z) { return pos3d(x,y,z);} | |
shape@ main_shape() | |
{ | |
// pyramid dimensions | |
double x = 50; | |
double y = 50; | |
double z = 50; | |
// radius of rounding sphere | |
double r=6; | |
// triangular pyramid | |
array<pos3d@> pnts = {p(-x+r, -y+r, 0+r), | |
p( x-r, -y+r, 0+r), | |
p( 0 , y-r, 0+r), | |
p( 0 , 0, z-r) | |
}; | |
solid@ pyramid = polyhedron(pnts); | |
// if radius greater than zero, run minkowski | |
if(r>0) return minkowski3d(pyramid,sphere(r)); | |
else return pyramid; | |
} | |
void main() | |
{ | |
shape@ obj = main_shape(); | |
obj.write_xcsg(GetInputFullPath(),secant_tolerance:0.01); | |
} |
This file contains hidden or 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
# simpler syntax version using convention over configuration ... rubyesque | |
base_radius = 6 | |
height = 50 | |
# defaults to 0,0,0 | |
my_pyramid = round_pyramid(base_radius height) | |
# alternate means to specify offset (saves creating a position argument to every function returning an object) | |
position = (x,y,z) = 0 | |
# example one: re-location of prior pyramid | |
at(position,my_pyramid) | |
# example two: re-creation from scratch with at() | |
my_pyramid = at(position,round_pyramid(base_radius,height)) | |
# function example | |
function round_pyramid(base_radius,height) { | |
points = { ... } | |
return polyhedron(points) # polyhedron assumes double which is passed up the chain to loosely typed arguments | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment