Skip to content

Instantly share code, notes, and snippets.

@acamilo
Forked from madhephaestus/sphere.groovy
Last active February 2, 2017 00:17
Show Gist options
  • Save acamilo/e9629fffdec42d29089e7a4b05093dd4 to your computer and use it in GitHub Desktop.
Save acamilo/e9629fffdec42d29089e7a4b05093dd4 to your computer and use it in GitHub Desktop.
import com.neuronrobotics.bowlerstudio.vitamins.Vitamins;
import eu.mihosoft.vrl.v3d.parametrics.*;
int sphereRadius = 125;
int flapRadius = 65;
CSG body = new Sphere(sphereRadius,40,40)// Spheres radius
.toCSG()// convert to CSG to display
CSG cavity = new Sphere(sphereRadius-5,40,40)// Spheres radius
.toCSG()// convert to CSG to display
CSG diskcylmask = new Cylinder(flapRadius, // Radius at the bottom
flapRadius, // Radius at the top
20, // Height
(int)30 //resolution
).toCSG().movez(105)//convert to CSG to display
CSG diskcylcut = new Cylinder(flapRadius+2, // Radius at the bottom
flapRadius+2, // Radius at the top
25, // Height
(int)30 //resolution
).toCSG().movez(100)//convert to CSG to display
CSG flap = diskcylmask.intersect(body);
CSG cutaway = new Cube((sphereRadius+1)*2,(sphereRadius+1),(sphereRadius+1)*2).toCSG().movey((sphereRadius+1)/2);
CSG TopRightFlap = flap.roty(45).setColor(javafx.scene.paint.Color.CYAN);
CSG TopLeftFlap = flap.roty(-45).setColor(javafx.scene.paint.Color.CYAN);;
CSG BotRightFlap = flap.roty(-225).setColor(javafx.scene.paint.Color.CYAN);;
CSG BotLeftFlap = flap.roty(225).setColor(javafx.scene.paint.Color.CYAN);;
CSG ServoFlapLeft = Vitamins.get("hobbyServo","hv6214mg").setColor(javafx.scene.paint.Color.CYAN)
.rotx(90).roty(180)
.movez(95).movex(12);
CSG ServoFlapRight = Vitamins.get("hobbyServo","hv6214mg").setColor(javafx.scene.paint.Color.CYAN)
.rotx(90).roty(180)
.movez(95).movex(-12);
CSG Chassis = body.difference([cavity,cutaway,diskcylcut.roty(45),diskcylcut.roty(225),diskcylcut.roty(-45),diskcylcut.roty(-225)]);
return [Chassis,TopRightFlap,TopLeftFlap,BotRightFlap,BotLeftFlap,ServoFlapLeft,ServoFlapRight];
//return vitaminFromScript;
//return [TopRightFlap,TopLeftFlap,BotRightFlap,BotLeftFlap]
//CSG tlcyl = diskcylmask.roty(-45);
//CSG blcyl = diskcylmask.roty(225);
//CSG brcyl = diskcylmask.roty(-225);
//return trcyl.intersect(body);
//return trcyl;
//return [flap]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment