Giter Site home page Giter Site logo

geoffder / scad-ml Goto Github PK

View Code? Open in Web Editor NEW

This project forked from namachan10777/scad-ml

1.0 1.0 0.0 9.28 MB

OpenSCAD DSL for OCaml

License: Boost Software License 1.0

OCaml 98.64% Makefile 0.14% Perl 0.05% Raku 0.33% Standard ML 0.07% Terra 0.77%

scad-ml's Introduction

OpenSCAD DSL for OCaml

Overview

This library provides an OCaml front-end to the OpenSCAD solid modelling language. All SCAD primitives and transformation functions are made available.

Notable differences from the OpenSCAD language

  • Angles are represented in radians (and converted to degrees when compiling to OpenSCAD).
  • linear_extrude and rotate_extrude have been renamed to extrude and revolve
  • The dimensional system (2D or 3D) each shape inhabits is tracked by the type system. This is used to restrict the operations that can be legally applied (e.g. 2D shapes cannot be moved off of the xy plane, extrude can only be applied to 2D shapes) and enforcing non-mixing of 2D and 3D shapes during boolean operations.
  • Additional modules providing sweeps, roundovers, and more, inspired largely by BOSL2, but also other OpenSCAD libraries such as dotSCAD, and PlotFunction.

Usage

open Scad_ml

let () =
  let scad_logo =
    let rad = 5.
    and fn = 720 in
    let cyl = Scad.cylinder ~fn ~center:true ~height:(rad *. 2.3) (rad /. 2.) in
    let cross_cyl = Scad.rotate (v3 0. (Float.pi /. 2.) 0.) cyl in
    Scad.union
      [ Scad.difference
          (Scad.sphere ~fn rad)
          [ cyl; cross_cyl; Scad.rotate (v3 0. 0. (Float.pi /. 2.)) cross_cyl ]
      ; Scad.color ~alpha:0.25 Color.Magenta cross_cyl
      ]
  in
  Scad.to_file "scad_logo.scad" scad_logo

OpenSCAD logo Generated scads can then be viewed with the OpenSCAD viewer as you normally would.

Documentation

Documentation is available online, covering the API as well as some walkthrough style examples.

Companion PPX

There is a companion ppx, [@@deriving scad] for generating transformation functions for user-defined records and abstract types made up of the Scad.t, along with their corresponding vector (V2.t or V3.t) types (and those composed of them) provided in this library.

Authors

  • @namachan10777
    • Original author of core DSL
  • @geoffder
    • Overhauled DSL with dimensional types
    • Additional vector transformation modules (e.g. Affine3, Quaternion, Plane)
    • Modules implementing 2d/3d vector point representations of paths and shapes along with utilities operating upon them to enable sweeps, roundovers, etc.

License

BSL-1.0

scad-ml's People

Contributors

geoffder avatar namachan10777 avatar smorimoto avatar

Stargazers

 avatar

Watchers

 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.