Giter VIP home page Giter VIP logo

scad-utils's Introduction

scad-utils

Utility libraries for OpenSCAD

Morphology

contains basic 2D morphology operations

inset(d=1)             - creates a polygon at an offset d inside a 2D shape
outset(d=1)            - creates a polygon at an offset d outside a 2D shape
fillet(r=1)            - adds fillets of radius r to all concave corners of a 2D shape
rounding(r=1)          - adds rounding to all convex corners of a 2D shape
shell(d,center=false)  - makes a shell of width d along the edge of a 2D shape
                       - positive values of d places the shell on the outside
                       - negative values of d places the shell on the inside
                       - center=true and positive d places the shell centered on the edge

Examples

With a basic sample polygon shape,

module shape() {
    polygon([[0,0],[1,0],[1.5,1],[2.5,1],[2,-1],[0,-1]]);
}

and $fn=32;.

  • inset(d=0.3) shape();

  • outset(d=0.3) shape();

  • rounding(r=0.3) shape();

  • fillet(r=0.3) shape();

*shell(d=0.3) shape();

*shell(d=-0.3) shape();

*shell(d=0.3,center=true) shape();

Mirror

contains simple mirroring functions

mirror_x()
mirror_y()
mirror_z()

example:

module arrow(l=1,w=.6,t=0.15) {
    mirror_y() polygon([[0,0],[l,0],[l-w/2,w/2],[l-w/2-sqrt(2)*t,w/2],[l-t/2-sqrt(2)*t,t/2],[0,t/2]]);
}

scad-utils's People

Contributors

dimo414 avatar oskarlinde avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scad-utils's Issues

WARNING: len() parameter could not be converted, in file scad-utils/trajectory.scad, line 7

Hi, the latest OpenSCAD version produces the warning above, for example when running the list-comprehension-demos/toothed-belt.scad

I thought that to be be trivially fixable, but I have found the following behavior hard to grasp:

vec_is_undef([1,2,3,undef], index_=3) == true
vec_is_undef([1,2,3,undef,4], index_=3) == false

What is the rationale behind that? Do we actually need it?

shapes.scad - where to find this module ?

I'm trying to use the scad-utils as described by mathgrl at https://mathgrrl.com/hacktastic/2018/11/knots-in-openscad-with-sweeper/

use <sweep.scad>
use <scad-utils/shapes.scad>

function f(a,b,t) = // rolling knot
[ a * cos (3 * t) / (1 - b* sin (2 t)),
a * sin( 3 * t) / (1 - b
sin (2 t)),
1.8 * b * cos (2 * t) /(1 - b
sin (2 *t))
];

a = 0.8;
b = sqrt (1 - a * a);

function shape() = circle(60, $fn=48);

step = 0.005;
path = [for (t=[0:step:1-step]) 200 * f(a,b,t*360)];
path_transforms = construct_transform_path(path);
sweep(shape(), path_transforms, true);

Lots of the code in sweeper seems to rely on scad-utils and includes something called shapes.scad from there.

Anyone know where to find that as its no longer here it seems ?

Sorry if this is a dull question

All help much appreciated.

Please clarify the license of the library

The library has lots of nice code which is generally useful, but without a clear license, it's basically not possible to distribute the code along with OpenSCAD or as separate package in Linux distributions. I hope you would like to see it included / distributed, so please add a license to make it possible.

r parameter in linear_extrude from morphology example

Hi, I found this example from 2014 which looks like something I've been after, except there is an 'r' parameter in linear_extrude which gets thrown up as a warning as it doesn't exist. Images of the example rendered from here: http://forum.openscad.org/Experiment-with-rounded-extrusions-td7928.html and my render which has only half of the round edges. Can anyone explain where the 'r' parameter in linear_extrude might be found?

scad1
scad2

use <scad-utils/morphology.scad>
eps = 0.01;

$fn=64;

module base() {
union() {
rounding(2) fillet(2) difference() {
square([50,40]);
translate([(50-25)/2,40-15]) square([25,20]);
}
rounding(0.25) square([50,10]);
}
}

difference() {
linear_extrude(height=10,r=0.25,convexity=3)
base();

    translate([0,0,-eps]) linear_extrude(height=10 + 2*eps,r=-1,convexity=3)
            translate([(50-30)/2,5])
                    rounding(2) square([30,15]);

    rotate([90,0,0])
            translate([5,2.5,-1])
                            linear_extrude(height=1+eps,r=[0.25,-0.25])  
                                    rounding(1) square([40,5]);

}

for (x = [6.25, 50-6.25])
translate([x, 40-6.25, 10])

            linear_extrude(height=5,r=[-.25,.25],chamfer=[0,1])
                    circle(r=2);

how to find help

Sorry, maybe I'm a dump guy.. please can you help me:
There is a Readme.md and there are the files. But there is almost NO connection between the two.
Readme shows a lot examples with "shape", but there is no "shape" in the files. And all the other files (except mirror) are not mentioned in the readme..? How can I use it (of course I can read the scad files and experiment, but is that expected)?

trajectory.scad documentation

This module seems to be what I'm looking for but I don't quite grasp how to control it. Is there some documentation about it?

spline and remove function

It appears that pull request #1 should have included the lists.scad file as well, as it adds the remove() function that is required by the spline() function.

hull

is this supposed to work ?

use <scad-utils/transformations.scad>
use <scad-utils/shapes.scad>
use <scad-utils/hull.scad>
use <list-comprehension-demos\skin.scad>

fn=32;
$fn=60;

r1 = 25;
r2 = 10;
R = 40;
th = 2;

function rhull(r)=[for(i=hull(r))r[i]];

module tube()
{

    difference()
    {
        skin([for(i=[0:fn])
              transform(
                rotation([0,180/fn*i,0])*translation([-R,0,0]), 
                rhull(concat(circle(r1+(r1-r2)/fn*i),square((r1+2.5*r1/2))))
        )
        ]);

//        echo( concat(circle(r1+(r1-r2)/2),square((r1+r2)*2)));
//        echo(rhull(concat(circle(r1+(r1-r2)/2),square((r1+r2)*2))));

        r1 = r1-th;
        r2 = r2-th;
        skin([for(i=[0:fn]) 
              transform(rotation([0,180/fn*i,0])*translation([-R,0,0]), 
                        circle(r1+(r1-r2)/fn*i))]);
    }
}

tube();

modified from here:
http://stackoverflow.com/questions/28842419/linear-rotational-extrude-at-the-same-time

shapes.scad: Winding order is inconsistent

In shapes.scad, the winding order of the shapes are inconsistent.

  • square(): clockwise
  • circle(): anti-clockwise
  • regular(): anti-clockwise (as it uses circle())
  • rectangle_profile(): anti-clockwise

This causes trouble when sweep()-ing (as in https://github.com/openscad/list-comprehension-demos/blob/master/sweep.scad) circle(), as the normals of the resulting polygon end up pointing inwards instead of outwards.

It would probably make sense to make all of the shapes have anti-clockwise winding order, to match the OpenSCAD polyhedron expectations.

(btw, I'm happy to submit a pull request to fix it if you agree)

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.