Last active
March 12, 2019 19:23
-
-
Save jyxiao1/b72ce2a1e3977fc7e5a530cfdbd27d69 to your computer and use it in GitHub Desktop.
a pair of Simon Glasses from "Tengan Toppa Gurren Lagann"
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
import eu.mihosoft.vrl.v3d.ext.quickhull3d.* | |
import eu.mihosoft.vrl.v3d.Vector3d | |
//Your code here | |
//cos^-1(((3.5)^2+(3.935)^2 - (1.8)^2)/(2*3.5*3.935)) | |
//2 to 1 ratio of glasses to face | |
double upperPointX = 0; | |
double upperPointY = 80; | |
double upperInnerPointX = 23; | |
double upperInnerPointY = 28; | |
double upperOuterPointX = 105; | |
double upperOuterPointY = 50; | |
double lowerInnerPointX = 41; | |
double lowerInnerPointY = -12; | |
double lowerOuterPointX = 54; | |
double lowerOuterPointY = -51; | |
double lowerPointX = 0; | |
double lowerPointY = -6; | |
double centerPointX = 0; | |
double centerPointY = 5; | |
double centerPointZ = 10; | |
liftZ = 5; | |
CSG noseHole = new Cylinder(2, // Radius at the bottom | |
0, // Radius at the top | |
40, // Height | |
(int)30 //resolution | |
).toCSG()//convert to CSG to display | |
.movez(50); | |
CSG nosesphere = new Sphere(1.6,// Spheres radius | |
40,//elevation Divisions | |
40)// vertical divisions | |
.toCSG()// convert to CSG to display | |
.movey(-6.5); | |
//hulledCubes = CSG.hullAll([cube,movedCube]) | |
def points = [new Vector3d(lowerPointX + 2.5, lowerPointY - 2, 0), | |
new Vector3d(lowerPointX - 2.5, lowerPointY - 2, 0), | |
new Vector3d(lowerPointX, lowerPointY, 2), | |
new Vector3d(lowerPointX, lowerPointY, 0)]; | |
CSG hullSection = HullUtil.hull(points) | |
nosesphere = CSG.hullAll([nosesphere, hullSection]) | |
//CSG hullSection = HullUtil.hull(points) | |
def topLpoints = [new Vector3d(centerPointX, centerPointY, centerPointZ), | |
new Vector3d(upperPointX,upperPointY, 0), | |
new Vector3d(centerPointX, centerPointY, 0), | |
new Vector3d(upperInnerPointX, upperInnerPointY, 0)]; | |
def topRpoints = [new Vector3d(-centerPointX, centerPointY, centerPointZ), | |
new Vector3d(-upperPointX,upperPointY,0), | |
new Vector3d(-centerPointX, centerPointY, 0), | |
new Vector3d(-upperInnerPointX, upperInnerPointY, 0)]; | |
def topRightLpoints = [new Vector3d(centerPointX, centerPointY, centerPointZ), | |
new Vector3d(upperOuterPointX, upperOuterPointY,0), | |
new Vector3d(centerPointX, centerPointY, 0), | |
new Vector3d(upperInnerPointX, upperInnerPointY, 0)]; | |
def topLeftRpoints = [new Vector3d(-centerPointX, centerPointY, centerPointZ), | |
new Vector3d(-upperOuterPointX,upperOuterPointY,0), | |
new Vector3d(-centerPointX, centerPointY, 0), | |
new Vector3d(-upperInnerPointX, upperInnerPointY, 0)]; | |
def topLeftLpoints = [new Vector3d(-centerPointX, centerPointY, centerPointZ), | |
new Vector3d(-upperOuterPointX, upperOuterPointY,0), | |
new Vector3d(-centerPointX, centerPointY, 0), | |
new Vector3d(-lowerInnerPointX, lowerInnerPointY, 0)]; | |
def topRightRpoints = [new Vector3d(centerPointX, centerPointY, centerPointZ), | |
new Vector3d(upperOuterPointX,upperOuterPointY,0), | |
new Vector3d(centerPointX, centerPointY, 0), | |
new Vector3d(lowerInnerPointX, lowerInnerPointY, 0)]; | |
def bottomRightRpoints = [new Vector3d(centerPointX, centerPointY, centerPointZ), | |
new Vector3d(lowerOuterPointX, lowerOuterPointY,0), | |
new Vector3d(centerPointX, centerPointY, 0), | |
new Vector3d(lowerInnerPointX, lowerInnerPointY, 0)]; | |
def bottomRightLpoints = [new Vector3d(centerPointX, centerPointY, centerPointZ), | |
new Vector3d(lowerOuterPointX, lowerOuterPointY,0), | |
new Vector3d(centerPointX, centerPointY, 0), | |
new Vector3d(lowerPointX, lowerPointY, 0)]; | |
def bottomLeftLpoints = [new Vector3d(-centerPointX, centerPointY, centerPointZ), | |
new Vector3d(-lowerOuterPointX, lowerOuterPointY, 0), | |
new Vector3d(-centerPointX, centerPointY, 0), | |
new Vector3d(-lowerInnerPointX, lowerInnerPointY, 0)]; | |
def bottomLeftRpoints = [new Vector3d(-centerPointX, centerPointY, centerPointZ), | |
new Vector3d(-lowerOuterPointX, lowerOuterPointY, 0), | |
new Vector3d(-centerPointX, centerPointY, 0), | |
new Vector3d(-lowerPointX, lowerPointY, 0)]; | |
CSG topL = HullUtil.hull(topLpoints); | |
CSG topR = HullUtil.hull(topRpoints); | |
CSG topRightR = HullUtil.hull(topRightRpoints); | |
CSG topRightL = HullUtil.hull(topRightLpoints); | |
CSG topLeftR = HullUtil.hull(topLeftRpoints); | |
CSG topLeftL = HullUtil.hull(topLeftLpoints); | |
CSG bottomLeftR = HullUtil.hull(bottomLeftRpoints); | |
CSG bottomLeftL = HullUtil.hull(bottomLeftLpoints); | |
CSG bottomRightR = HullUtil.hull(bottomRightRpoints); | |
CSG bottomRightL = HullUtil.hull(bottomRightLpoints); | |
CSG glasses = CSG.unionAll([topL, | |
topR, | |
topRightR, | |
topRightL, | |
topLeftR, | |
topLeftL, | |
bottomLeftR, | |
bottomLeftL, | |
bottomRightR, | |
bottomRightL | |
]); | |
glasses = glasses.difference(nosesphere); | |
glasses = glasses.setName("simonGlasses_v3"); | |
return [glasses, noseHole , hullSection]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment