Skip to content

Instantly share code, notes, and snippets.

@Octogonapus
Last active December 24, 2017 02:03
Show Gist options
  • Save Octogonapus/3254044f51b38f752cd49b4a326728d6 to your computer and use it in GitHub Desktop.
Save Octogonapus/3254044f51b38f752cd49b4a326728d6 to your computer and use it in GitHub Desktop.
Place CSGs along an ellipse
CSG getEllipse(double xRadius, double yRadius, double z) {
List<Vector3d> points = [];
for (double i = 0; i < 2 * Math.PI; i += 0.01) {
points.add(new Vector3d((xRadius*yRadius*Math.cos(i)) / Math.sqrt((Math.pow((yRadius*Math.cos(i)), 2) + Math.pow((xRadius*Math.sin(i)), 2))),
(xRadius*yRadius*Math.sin(i)) / Math.sqrt((Math.pow((yRadius*Math.cos(i)), 2) + Math.pow((xRadius*Math.sin(i)), 2))),
0));
}
return Extrude.points(new Vector3d(0, 0, z), points);
}
return getEllipse(8, 4, 5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment