Skip to content

Instantly share code, notes, and snippets.

@madhephaestus
Last active August 9, 2021 01:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 14 You must be signed in to fork a gist
  • Save madhephaestus/f01548f0e4f85bd3f08fdfdd503510b4 to your computer and use it in GitHub Desktop.
Save madhephaestus/f01548f0e4f85bd3f08fdfdd503510b4 to your computer and use it in GitHub Desktop.
Demonstrate the new bezier extrude API
/.project
/.classpath
/.cproject
/cache/
/*.class
import eu.mihosoft.vrl.v3d.Extrude;
CSG part = new Cube(10).toCSG()
ArrayList<CSG> parts = new ArrayList<CSG>()
int numParts = 10
for(int i=0;i<numParts;i++){
//println scale
parts.add(part.clone())
}
// A full bezier extrud with the gaps between the parts filled with a convex hull of the part
def fullBezier = Extrude.bezier( parts,
[(double)0.0,(double)0.0,(double)300.0], // Control point one
[(double)200.0,(double)200.0,(double)-150.0], // Control point two
[(double)200.0,(double)200.0,(double)300.0]// Endpoint
)
// thake the parts and just move to locations along the bezier curve
def movedCubesBezier = Extrude.moveBezier( parts,
[(double)0,(double)0,(double)300], // Control point one
[(double)200,(double)200,(double)-150], // Control point two
[(double)200,(double)200,(double)300] // Endpoint
).collect{
it.movey(200)
}
// This is for creating a set of frame transformations from the bezier parameters
// this can be used for complex part creation or for path planning
ArrayList<Transform> transforms = Extrude.bezierToTransforms( new Vector3d(0,(double)0,(double)300), // Control point one
new Vector3d((double)200,(double)200,(double)-150), // Control point two
new Vector3d((double)200,(double)200,(double)300), // Endpoint
numParts// Iterations
)
fullBezier.addAll(movedCubesBezier)
return fullBezier
import eu.mihosoft.vrl.v3d.svg.*;
import eu.mihosoft.vrl.v3d.Extrude;
File f = ScriptingEngine
.fileFromGit(
"https://gist.github.com/1606010b686494cea33527b71c98570a.git",//git repo URL
"master",//branch
"airFoil.svg"// File from within the Git repo
)
SVGLoad s = new SVGLoad(f.toURI())
ArrayList<CSG>foil = s.extrude(0.01,0.01)
CSG part = foil.get(0)
.union(foil)
.roty(90)
.rotx(180)
.toZMin()
.toYMin()
ArrayList<CSG> parts = new ArrayList<CSG>()
int numParts = 80
for(int i=0;i<numParts;i++){
double scale = (5+4*Math.cos(Math.PI*1*i/numParts)
+0.1*Math.sin(Math.PI*30*i/numParts)
)
double twistAngle = Math.toDegrees(Math.cos(Math.PI*2*i/numParts))
//println scale
parts.add(
part.scale(scale)
.rotx(twistAngle)
)
}
return Extrude.bezier( parts,
[(double)00.0,(double)0.0,(double)300.0], // Control point one
[(double)50.0,(double)50,(double)300.0], // Control point two
[(double)50.0,(double)50.0,(double)300.0] // Endpoint
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment