This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = 8; | |
height = 40; | |
width = 50; // distance across flats of polygon (when n is even) | |
rxy = 8; | |
rz = 3; | |
width2 = 30; | |
rxy2 = rxy*width2/width; | |
rz2 = 0.1; // small but nonzero |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$fs=0.5; | |
$fa=1; | |
// example usage | |
chamfer_extrude(height=10,ch1=-3,ch2=3) { | |
hull() { | |
translate([-10,0]) circle(5, $fn=64); | |
translate([10,0]) circle(5, $fn=64); | |
} | |
square([10,30],center=true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Demo of using complex numbers to map one 2D point to another. | |
// Performs rotate and/or scale transform in one operation, without any | |
// transcendental (trigonometric) functions nor irrational numbers*. | |
// *please ignore the circular input data | |
// Enable animation for demo! | |
// multiply complex numbers | |
function cmul(c1,c2) = let(a=c1[0],b=c1[1],c=c2[0],d=c2[1]) | |
[a*c-b*d, a*d+b*c]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If the design does not create a "sync" clock domain, it is created by the nMigen build system | |
# using the platform default clock (and default reset, if any). | |
from nmigen import * | |
from nmigen_boards.de10_nano import * | |
class Blinky(Elaboratable): | |
def elaborate(self, platform): | |
leds = Array(platform.request("led", i) for i in range(0,8)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module rotate_extrude3D(clearance, bounds=[1000,1000]) { | |
rotate_extrude() | |
intersection() { // clip to positive x axis before rotate_extrude | |
translate([0,-bounds[1]/2]) square(bounds); | |
offset(delta=clearance) // add clearance to profile | |
union() for(a=[-90:$fa:90]) // union projections from multiple angles | |
projection() rotate([-90,a]) children(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fan=120; | |
ductl=110; | |
ductw=40; | |
h=150; | |
wallTh = 2; | |
module transition(h,l1,w1,l2,w2,eps=0.01) { | |
hull() { | |
cube([l1,w1,eps], center=true); | |
translate([0,0,h-eps]) cube([w2,l2,eps], center=true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$fn = 100; | |
module rounded_cube(size,r,center=false) | |
{ | |
s = is_list(size) ? size : [size,size,size]; | |
translate(center ? -s/2 : [0,0,0]) | |
hull() { | |
translate([ r, r, r]) sphere(r=r); | |
translate([ r, r,s.z-r]) sphere(r=r); | |
translate([ r,s.y-r, r]) sphere(r=r); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// older versions of OpenSCAD do not support "angle" parameter for rotate_extrude | |
// this module provides that capability even when using older versions (such as thingiverse customizer) | |
module rotate_extrude2(angle = 360, convexity = 2, size = 1000) { | |
module angle_cut(angle = 90, size = 1000) { | |
x = size*cos((angle / 2)); | |
y = size*sin((angle / 2)); | |
translate([0, 0, -size]) linear_extrude((2 * size)) polygon([[0, 0], [x, y], [x, size], [-size, size], [-size, -size], [x, -size], [x, -y]]); | |
} | |
// support for angle parameter in rotate_extrude was added after release 2015.03 | |
// Thingiverse customizer is still on 2015.03 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use <functional.scad> | |
$fa = 0.1; | |
$fs = 0.1; | |
module rounded_cube(size, r=0, center=false) { | |
s = is_array(size) ? size : [size,size,size]; | |
c = is_array(center) ? | |
[center.x ? 0 : s.x, center.y ? 0: s.y, center.z ? 0 : s.z]/2 : | |
(center ? 0 : s/2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// @file segmented_bit_sieve.cpp | |
/// @author Kim Walisch, <kim.walisch@gmail.com> | |
/// @brief This is an implementation of the segmented sieve of | |
/// Eratosthenes which uses a bit array with 16 numbers per | |
/// byte. It generates the primes below 10^10 in 7.25 seconds | |
/// on an Intel Core i7-6700 3.4 GHz CPU. | |
/// @license Public domain. | |
#include <iostream> | |
#include <algorithm> |