double starPointRadius = halfTableWidth * (1.0 - cut.relStarLength)
+ radius * cut.relStarLength;
double lowerGirdleInner = radius * (1.0 - cut.relLowerHalfLength);
MeshBuilder b = MeshBuilder.fromCylinder(radius, -culetBottom, 64);
b.translate(new Vector3(0, 0, culetBottom));
for (int i = 0; i < 8; i++) {
double theta0 = 2.0 * Math.PI * ((double) i) / 8.0;
double theta1 = 2.0 * Math.PI * (((double) i) + 0.5) / 8.0;
double theta2 = 2.0 * Math.PI * (((double) i) + 1.0) / 8.0;
double theta3 = 2.0 * Math.PI * (((double) i) + 1.5) / 8.0;
double cost0 = Math.cos(theta0);
double sint0 = Math.sin(theta0);
double cost1 = Math.cos(theta1);
double sint1 = Math.sin(theta1);
double cost2 = Math.cos(theta2);
double sint2 = Math.sin(theta2);
double cost3 = Math.cos(theta3);
double sint3 = Math.sin(theta3);
Point3 p = new Point3(halfTableDiag * cost1, halfTableDiag * sint1, 0.0);
Point3 q = new Point3(radius * cost1, radius * sint1, -crownHeight);
Point3 r;
Basis3 basis = Basis3.fromUW(p.vectorTo(q), Vector3.K);
Plane3 planeKite = Plane3.throughPoint(p, basis);
b.slice(planeKite, true);
q = new Point3(halfTableDiag * cost3, halfTableDiag * sint3, 0.0);
r = new Point3(starPointRadius * cost2, starPointRadius * sint2, 0.0);
Ray3 ray = new Ray3(r, Vector3.K);
r = ray.pointAt(planeKite.intersect(ray));
Plane3 planeStar = Plane3.throughPoints(q, p, r);
b.slice(planeStar, true);
p = new Point3(radius * cost2, radius * sint2, -crownHeight);
q = new Point3(radius * cost1, radius * sint1, -crownHeight);
Plane3 planeGirdle = Plane3.throughPoints(q, p, r);
b.slice(planeGirdle, true);
q = new Point3(radius * cost3, radius * sint3, -crownHeight);
planeGirdle = Plane3.throughPoints(p, q, r);
b.slice(planeGirdle, true);
p = new Point3(radius * cost1, radius * sint1, lowerMainTop);
q = new Point3(0.0, 0.0, lowerMainTop - pavilionPointDepth);
basis = Basis3.fromUW(p.vectorTo(q), Vector3.NEGATIVE_K);
Plane3 planeMain = Plane3.throughPoint(p, basis);
b.slice(planeMain, true);
q = new Point3(radius * cost0, radius * sint0, lowerMainTop);
r = new Point3(lowerGirdleInner * cost0, lowerGirdleInner * sint0, 0.0);
ray = new Ray3(r, Vector3.NEGATIVE_K);
r = ray.pointAt(planeMain.intersect(ray));
planeGirdle = Plane3.throughPoints(p, q, r);
b.slice(planeGirdle, true);
q = new Point3(radius * cost2, radius * sint2, lowerMainTop);
r = new Point3(lowerGirdleInner * cost2, lowerGirdleInner * sint2, 0.0);
ray = new Ray3(r, Vector3.NEGATIVE_K);
r = ray.pointAt(planeMain.intersect(ray));
planeGirdle = Plane3.throughPoints(q, p, r);
b.slice(planeGirdle, true);
}
b.mergeVertices(MathUtil.EPSILON);
return b;
}