Git Product home page Git Product logo

arc.scad's Introduction

arc.scad

functions for plotting arcs in SCAD

Syntax

array<array<x,y>> arc(x, y, from, to, [radius], [diameter], [$fn], [$fa], [$fs])
x number The center x point of the arc
y number The center y point of the arc
from number The starting angle of the arc
to number The ending angle of the arc
radius number (optional) The radius of the arc
diameternumber (optional) The diameter of the arc
$fn number (optional) The number of segments of the arc
$fa number (optional) The angle the arc will be segmented by
$fs number (optional) The magnitude the arc will be segmented by
returns array<array<number, number>>Returns the collection of 2d points for the arc

x, y, from, to and either radius or diameter are required. The default segment setting is $fs=1.

Usage

// Draws a 90 degree pie slice starting at 45 degrees
polygon(points = concat(
  [[0,0]], // center point
  arc(0,0,45,135,radius=50)
));

pie-slice

// Draws a square with rounded corners
size = 20;
corner = 5;
polygon(points = concat(
  arc(corner,corner,-90,-180,radius=corner), // lower-left corner
  arc(size-corner,corner,180,90,radius=corner), // lower-right corner
  arc(size-corner,size-corner,90,0,radius=corner), // upper-right corner
  arc(corner,size-corner,0,-90,radius=corner) // upper-left corner
));

rounded-square

// Compares two arcs set to $fn=5 (i.e. 5 "total" segments)
polygon(points = concat(
    [[0,0]],
    arc(0,0,0,90,20,$fn=5)
));
        
polygon(points = concat(
    [[30,0]],
    arc(30,0,0,90,40,$fn=5)
));

fn

// Compares two arcs set to $fa=5 (i.e. segment per 5 degrees)
polygon(points = concat(
    [[0,0]],
    arc(0,0,0,90,20,$fa=5)
));
        
polygon(points = concat(
    [[30,0]],
    arc(30,0,0,90,40,$fa=5)
));

fn

// Compares two arcs set to $fs=5 (i.e. segment per 5mm)
polygon(points = concat(
    [[0,0]],
    arc(0,0,0,90,20,$fs=5)
));
        
polygon(points = concat(
    [[30,0]],
    arc(30,0,0,90,40,$fs=5)
));

fn

arc.scad's People

Watchers

Mark Greenwald 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.