caltrops.frink

Download or view caltrops.frink in plain text format


/** This generates a caltrops for 3-D printing. */

res = 254/inch            // Resolution of model in voxels/inch

length = 1 inch           // Leg length from center
baseRadius = .2 inch      // Radius of base of leg
c = length res / sqrt[3]  // Scaling factor to make voxels come out right

// The vertices of the tetrahedron.  These need to be scaled by c.
// There are other ways of calculating the vertices.  The angle between vertices
// is arccos[-1/3] or 109.47122063449 degrees.
vertices = [[1,1,1], [1,-1,-1], [-1,1,-1], [-1,-1,1]]

v = undef

// Make legs
for [x,y,z] = vertices
{
   v2 = leg[x c, y c, z c, baseRadius res]
   v = v2.union[v]   //  v is allowed to be null in which case v2 is copied
}

v.projectX[undef].show["X"]
v.projectY[undef].show["Y"]
v.projectZ[undef].show["Z"]

filename = "caltrops.obj"
print["Writing $filename..."]
w = new Writer[filename]
w.println[v.toObjFormat["v", 1/(res mm)]]
w.close[]
println["done."]

leg[tipx, tipy, tipz, baseRadius] :=
{
   return callJava["frink.graphics.VoxelArray", "makeTaperedCappedCylinder", [0,0,0, tipx, tipy, tipz, baseRadius, 0]]
}


Download or view caltrops.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 19975 days, 2 hours, 53 minutes ago.