Giter Club home page Giter Club logo

jsolid's Introduction

jsolid is a java library for Constructive Solid Geometry that internally uses JCSG library which uses binary space partitioning algorithm. It's great for programmatically generating STL shapes for 3d printer.

Tutorial

To use jsolid you need download latest release jar. Whole API is available via static methods of JSolid class so all you need is to import it by adding following line (which is omitted for simplicity in all following examples). You may also want to add this line to favorites in your IDE.

import static com.perunlabs.jsolid.JSolid.*;

All curved (rounded) edges are approximated with finite precision, which is configured by specifying maximal distance allowed between required curve and closest point of approximated solid.

config().setCircleToPolygonPrecision(0.1);

Once you build your solid you can store it as STL file using

com.perunlabs.jsolid.d3.Stl.toStl(solid, "path/on/disk");

Examples

simple cuboid (preview)

cuboid(2, 4, 8);

cuboid with rounded corners (preview)

cuboid(5, 5, 5)
  .cornerR(z(), 1);

simple cylinder (preview)

cylinder(5, 10);

cylinder with many segments (preview)

cylinder(10, 2)
  .addSegment(5, 10)
  .addFunnel(3, 2)
  .addSegment(4);

rotated (preview)

cylinder(2, 10)
  .rotate(y(), degrees(45));

adding solids (preview)

cylinder(2, 10)
  .add(cuboid(10, 2, 5));

subtracting solids (preview)

cylinder(2, 10)
  .sub(cuboid(10, 2, 5));

intersecting solids (preview)

cylinder(2, 10)
  .intersect(cuboid(10, 2, 5));

adding with shift (preview)

cylinder(3, 1)
  .add(cuboid(6, 6, 1).moveBy(vx(5)));

subtracting with alignment (preview)

cuboid(4, 4, 4)
  .sub(cylinder(1, 1), align(maxZ()));

subtracting with two alignments (preview)

cuboid(4, 4, 4)
  .sub(cuboid(1, 1, 4), align(maxX()), align(minY()));

adding with outside alignment (preview)

cuboid(4, 4, 4)
  .add(cylinder(2, 4), alignOutside(maxZ()));

adding with outside alignment and margin (preview)

cuboid(4, 4, 4)
  .add(cylinder(2, 1), alignOutside(maxZ(), 2));

convex hull (preview)

cuboid(4, 4, 1)
  .add(cylinder(1, 1).moveBy(vx(5)))
  .convexHull();

prism with regular polygon as base (preview)

prism(regularPolygon(4, 8), 4);

cloned step forming stairs (preview)

cuboid(10, 4, 2)
  .clone(30, (i, s) -> s.moveBy(v(30, 0, i * 2)).rotate(z(), degrees(i * 6)));

jsolid's People

Contributors

mikosik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.