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 58 59 60 61 62 63 64 65
|
####
# Step 0: load helper functions
####
script("3d_printing_helper_functions.pl");
####
# Step 1: Generate tropical curve as a _polyhedral complex_
####
# constructing tropical quadric surface
$mQuadratic = [[2,0,0,0], [1,1,0,0], [1,0,1,0], [1,0,0,1],
[0,1,1,0], [0,1,0,1], [0,0,1,1], [0,2,0,0],
[0,0,2,0], [0,0,0,2]];
$cQuadratic = [1,-1/4,-2/4,-3/4,-3/4,-4/4,-5/4,2/4,0,-2/4];
$TQuadratic = new tropical::Hypersurface<Min>(MONOMIALS=>$mQuadratic,
COEFFICIENTS=>$cQuadratic);
# constructing tropical cubic surface
$mCubic = [[3,0,0,0], [0,3,0,0], [0,0,3,0], [0,0,0,3],
[1,1,1,0], [1,1,0,1], [1,0,1,1], [0,1,1,1],
[2,1,0,0], [2,0,1,0], [2,0,0,1], [1,2,0,0],
[1,0,2,0], [1,0,0,2], [0,2,1,0], [0,2,0,1],
[0,1,2,0], [0,1,0,2], [0,0,2,1], [0,0,1,2]];
$cCubic = [3,3,3,3,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1];
$TCubic = new tropical::Hypersurface<Min>(MONOMIALS=>$mCubic,
COEFFICIENTS=>$cCubic);
# constructing a tropical sextic curve as the stable intersection
# of a quadratic and a cubic surface
$tropicalCurveTmp = tropical::intersect($TQuadratic,$TCubic);
$tropicalCurve = new fan::PolyhedralComplex(VERTICES=>$tropicalCurveTmp->VERTICES->minor(All,~[1]),MAXIMAL_POLYTOPES=>$tropicalCurveTmp->MAXIMAL_POLYTOPES,INPUT_LINEALITY=>$tropicalCurveTmp->LINEALITY_SPACE->minor(All,~[1]));
####
# Step 2: generate a tropical surface for framing. The surface should contains the curve and be a _polyhedral complex_
####
# using the previously constructed tropical quadratic surface
$tropicalSurface = $TQuadratic;
$tropicalSurface = new fan::PolyhedralComplex(VERTICES=>$tropicalSurface->VERTICES->minor(All,~[1]),MAXIMAL_POLYTOPES=>$tropicalSurface->MAXIMAL_POLYTOPES,INPUT_LINEALITY=>$tropicalSurface->LINEALITY_SPACE->minor(All,~[1]));
####
# Step 3: create a bounding box
####
$boundingBox = generateBoundingBox($tropicalCurve);
# # ALTERNATIVE: create a bounding box manually
# $boundingBox = scale(cube(3),3);
####
# Step 4: create .scad file
####
$tropicalSurfaceFrame = intersectWithBoundingBoxForFraming($tropicalSurface,$boundingBox);
$tropicalCurveBounded = intersectWithBoundingBox($tropicalCurve,$boundingBox);
$filename = "tropicalCurve.scad";
generateSCADFileForCurve($tropicalSurfaceFrame,$tropicalCurveBounded,$filename);
|