Added files for the new iteration (work in progress)
parent
06e598c4d8
commit
721ba6f7ec
|
@ -0,0 +1,186 @@
|
|||
// This file is part of Cyclone PCB Factory: an open-source 3D printable CNC machine for PCB manufacture
|
||||
// http://reprap.org/wiki/Cyclone_PCB_Factory
|
||||
// Original author: Carlosgs (http://carlosgs.es)
|
||||
// License: Attribution - Share Alike - Creative Commons (http://creativecommons.org/licenses/by-sa/3.0/)
|
||||
// Designed with http://www.openscad.org/
|
||||
|
||||
|
||||
// Include necessary libraries
|
||||
use <libs/obiscad/vector.scad>
|
||||
use <libs/obiscad/attach.scad>
|
||||
use <libs/obiscad/bcube.scad>
|
||||
use <libs/standard_parts.scad>
|
||||
use <libs/hole_for_screw.scad>
|
||||
|
||||
|
||||
|
||||
|
||||
// Parameters for the bottom base
|
||||
base_size_X = 304.8;
|
||||
base_size_Y = 261.62;
|
||||
base_thickness = 8;
|
||||
base_corner_radius = 20;
|
||||
base_corner_res = 0;
|
||||
|
||||
|
||||
// Parameters for the axes sizes
|
||||
axes_Xsmooth_rodLen = 295;
|
||||
axes_Ysmooth_rodLen = 255;
|
||||
axes_Zsmooth_rodLen = 150;
|
||||
|
||||
axes_Xthreaded_rodLen = 300;
|
||||
axes_Ythreaded_rodLen = 300;
|
||||
axes_Zthreaded_rodLen = 100;
|
||||
|
||||
axes_Xsmooth_rodD = 8.5;
|
||||
axes_Ysmooth_rodD = 8.5;
|
||||
axes_Zsmooth_rodD = 8.5;
|
||||
|
||||
axes_Xthreaded_rodD = 8;
|
||||
axes_Ythreaded_rodD = 8;
|
||||
axes_Zthreaded_rodD = 8;
|
||||
|
||||
// Parameters for the axes reference position
|
||||
// Note: The reference coordinates are centered like this:
|
||||
// Y axis reference is the Y smooth rod, BACK of LEFT FRAME
|
||||
// X axis reference is the X threaded rod edge, LEFT FRAME
|
||||
// Z axis reference is the Z threaded rod, at the height of the Z nut, and relative to the X reference
|
||||
axes_Yreference_height = 30;
|
||||
axes_Xreference_height = 60; // relative to Y reference
|
||||
axes_Zreference_height = 35; // relative to X reference
|
||||
|
||||
axes_Xreference_posY = 60; // relative to Y reference. Moves the X axis to the front of the machine
|
||||
axes_Zreference_posY = 15; // relative to X reference. Positions Z nut between the Y rods
|
||||
|
||||
|
||||
axes_Ysmooth_separation = 210;
|
||||
axes_Xsmooth_separation = 40;
|
||||
|
||||
|
||||
// Parameters for the axis-nut offsets (along same axes)
|
||||
axes_Xnut_offset = 10;
|
||||
axes_Ynut_offset = 0;
|
||||
|
||||
// Carriage positions (for rendering)
|
||||
axes_Xcarriage_pos = 70;
|
||||
axes_Ycarriage_pos = 40;
|
||||
axes_Zcarriage_pos = 20;
|
||||
|
||||
// Draw auxiliary reference (LCS axis, etc)
|
||||
draw_references = true;
|
||||
|
||||
|
||||
|
||||
|
||||
// Useful command reference:
|
||||
//use <MCAD/motors.scad>
|
||||
//stepper_motor_mount(nema_standard=17, slide_distance=10, $fn=40, mochup=true);
|
||||
|
||||
//use <MCAD/boxes.scad>
|
||||
//roundedBox([10,20,30], radius=2, sidesonly=false, $fn=60);
|
||||
|
||||
//use <libs/obiscad/bcube.scad>
|
||||
//bcube([20,20,10],cr=4, cres=10);
|
||||
|
||||
//include <MCAD/stepper.scad>
|
||||
//motor(Nema17, size=NemaMedium, dualAxis=false);
|
||||
|
||||
//use <MCAD/teardrop.scad>
|
||||
//teardrop(radius=10, length=20, angle=90);
|
||||
|
||||
//use <MCAD/nuts_and_bolts.scad>
|
||||
//nutHole(size=3, tolerance=0.5, proj=-1);
|
||||
//boltHole(size=3, length=10, tolerance=0.5, proj=-1, $fn=40);
|
||||
|
||||
//use <libs/hole_for_screw.scad>
|
||||
//hole_for_screw(size=3,length=15,nutDepth=0,nutAddedLen=3.5,captiveLen=0);
|
||||
|
||||
|
||||
|
||||
|
||||
//-- Connector definitions
|
||||
// att. point att. axis roll
|
||||
//C_origin = [ [0,0,0], [0,0,1], 0 ];
|
||||
//C_other = [ [0,0,20], [0,1,1], 5 ];
|
||||
|
||||
//
|
||||
//if(draw_references) {
|
||||
// %frame();
|
||||
// %connector(C_origin);
|
||||
// %connector(C_other);
|
||||
//}
|
||||
|
||||
//attach(a,origin) cylinder(r=0.25, h=20, $fn=3);
|
||||
|
||||
|
||||
|
||||
// BEGIN ASSEMBLING THE DESIGN
|
||||
|
||||
// Dummy part for allowing rendering of all objects with %
|
||||
cube([10,20,30]);
|
||||
|
||||
// Main base for the machine
|
||||
beveledBase([base_size_X,base_size_Y,base_thickness], radius=base_corner_radius, res=base_corner_res);
|
||||
//%color("brown") translate([0,0,-base_thickness/2]) bcube([base_size_X,base_size_Y,base_thickness], cr=base_corner_radius, cres=base_corner_res);
|
||||
|
||||
|
||||
// A4 paper sheet for reference
|
||||
standard_paperSheet_A4();
|
||||
|
||||
|
||||
// Cyclone foot stands
|
||||
foot_offset = 40;
|
||||
translate([0,0,-base_thickness]) {
|
||||
translate([base_size_X/2-foot_offset,base_size_Y/2-foot_offset])
|
||||
rubberFoot();
|
||||
translate([-base_size_X/2+foot_offset,base_size_Y/2-foot_offset])
|
||||
rubberFoot();
|
||||
translate([-base_size_X/2+foot_offset,-base_size_Y/2+foot_offset])
|
||||
rubberFoot();
|
||||
translate([base_size_X/2-foot_offset,-base_size_Y/2+foot_offset])
|
||||
rubberFoot();
|
||||
}
|
||||
|
||||
// CHANGE REFERENCE POSITION to the left frame, Y smooth rod end
|
||||
translate([axes_Ysmooth_separation/2,-axes_Ysmooth_rodLen/2,axes_Yreference_height]) {
|
||||
if(draw_references) %frame();
|
||||
}
|
||||
|
||||
// CHANGE REFERENCE POSITION to the left frame, Y smooth rod end
|
||||
translate([axes_Ysmooth_separation/2,-axes_Ysmooth_rodLen/2,axes_Yreference_height]) {
|
||||
if(draw_references) %frame();
|
||||
|
||||
// Draw left Y smooth rod
|
||||
standard_rod(diam=axes_Ysmooth_rodD, length=axes_Ysmooth_rodLen, threaded=false);
|
||||
// Draw right Y smooth rod
|
||||
translate([-axes_Ysmooth_separation,0,0])
|
||||
standard_rod(diam=axes_Ysmooth_rodD, length=axes_Ysmooth_rodLen, threaded=false);
|
||||
|
||||
// CHANGE REFERENCE POSITION to the left frame, Y smooth rod end
|
||||
translate([axes_Xsmooth_rodLen/2-axes_Ysmooth_separation/2,axes_Xreference_posY,axes_Xreference_height]) {
|
||||
if(draw_references) %frame();
|
||||
// Draw X threaded rod
|
||||
rotate([0,0,90]) standard_rod(diam=axes_Xsmooth_rodD, length=axes_Xsmooth_rodLen, threaded=true);
|
||||
// Draw bottom X smooth rod
|
||||
translate([0,axes_Xsmooth_separation,0])
|
||||
rotate([0,0,90]) standard_rod(diam=axes_Xsmooth_rodD, length=axes_Xsmooth_rodLen, threaded=false);
|
||||
// Draw top X smooth rod
|
||||
translate([0,0,axes_Xsmooth_separation])
|
||||
rotate([0,0,90]) standard_rod(diam=axes_Xsmooth_rodD, length=axes_Xsmooth_rodLen, threaded=false);
|
||||
|
||||
// CHANGE REFERENCE POSITION to the X carriage (nut)
|
||||
translate([-axes_Xcarriage_pos,0,0]) {
|
||||
if(draw_references) %frame();
|
||||
cyclone_X_carriage();
|
||||
|
||||
// CHANGE REFERENCE POSITION to the X carriage (nut)
|
||||
translate([0,axes_Zreference_posY,axes_Zreference_height]) {
|
||||
if(draw_references) %frame();
|
||||
cyclone_Z_carriage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
// This file is part of Cyclone PCB Factory: a 3D printable CNC machine for PCB manufacture
|
||||
// http://reprap.org/wiki/Cyclone_PCB_Factory
|
||||
// Author: Carlosgs (http://carlosgs.es)
|
||||
// License: Attribution - Share Alike - Creative Commons (http://creativecommons.org/licenses/by-sa/3.0/)
|
||||
|
||||
include <MCAD/nuts_and_bolts.scad>
|
||||
|
||||
module hole_for_screw(size=3,length=20,nutDepth=5,nutAddedLen=0,captiveLen=0,tolerance=0.5) {
|
||||
*translate([0,-length/2+nutDepth,0])
|
||||
rotate([90,0,0])
|
||||
hull() {
|
||||
translate([0,0,nutDepth])
|
||||
scale([1,1,0.01])
|
||||
nutHole(size=size, tolerance=tolerance, proj=-1);
|
||||
scale([1,1,0.01]) nutHole(size=size, tolerance=tolerance, proj=-1);
|
||||
}
|
||||
radius = METRIC_NUT_AC_WIDTHS[size]/2+tolerance;
|
||||
height = METRIC_NUT_THICKNESS[size]+tolerance;
|
||||
translate([0,-length/2+height+nutAddedLen+nutDepth-0.01,0])
|
||||
scale([1,(height+nutAddedLen)/height,1])
|
||||
rotate([90,0,0])
|
||||
hull() {
|
||||
nutHole(size=size, tolerance=tolerance, proj=-1);
|
||||
translate([0,captiveLen,0])
|
||||
nutHole(size=size, tolerance=tolerance, proj=-1);
|
||||
}
|
||||
translate([0,length/2-2.6,0])
|
||||
rotate([90,0,0])
|
||||
render() boltHole(size=size, length=length-2.6+0.5, tolerance=tolerance-0.1, proj=-1, $fn=40);
|
||||
}
|
||||
|
||||
hole_for_screw(size=3,length=20,nutDepth=0,nutAddedLen=0,captiveLen=10);
|
|
@ -0,0 +1,148 @@
|
|||
//---------------------------------------------------------------
|
||||
//-- Openscad Attachment library
|
||||
//-- Attach parts easily. Make your designs more reusable and clean
|
||||
//---------------------------------------------------------------
|
||||
//-- This is a component of the obiscad opescad tools by Obijuan
|
||||
//-- (C) Juan Gonzalez-Gomez (Obijuan)
|
||||
//-- Sep-2012
|
||||
//---------------------------------------------------------------
|
||||
//-- Released under the GPL license
|
||||
//---------------------------------------------------------------
|
||||
|
||||
use <vector.scad>
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
//-- Draw a connector
|
||||
//-- A connector is defined a 3-tuple that consist of a point
|
||||
//--- (the attachment point), and axis (the attachment axis) and
|
||||
//--- an angle the connected part should be rotate around the
|
||||
//-- attachment axis
|
||||
//--
|
||||
//--- Input parameters:
|
||||
//--
|
||||
//-- Connector c = [p , n, ang] where:
|
||||
//--
|
||||
//-- p : The attachment point
|
||||
//-- v : The attachment axis
|
||||
//-- ang : the angle
|
||||
//--------------------------------------------------------------------
|
||||
module connector(c)
|
||||
{
|
||||
//-- Get the three components from the connector
|
||||
p = c[0];
|
||||
v = c[1];
|
||||
ang = c[2];
|
||||
|
||||
//-- Draw the attachment poing
|
||||
color("Gray") point(p);
|
||||
|
||||
//-- Draw the attachment axis vector (with a mark)
|
||||
translate(p)
|
||||
rotate(a=ang, v=v)
|
||||
color("Gray") vector(unitv(v)*6, l_arrow=2, mark=true);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//-- ATTACH OPERATOR
|
||||
//-- This operator applies the necesary transformations to the
|
||||
//-- child (attachable part) so that it is attached to the main part
|
||||
//--
|
||||
//-- Parameters
|
||||
//-- a -> Connector of the main part
|
||||
//-- b -> Connector of the attachable part
|
||||
//-------------------------------------------------------------------------
|
||||
module attach(a,b)
|
||||
{
|
||||
//-- Get the data from the connectors
|
||||
pos1 = a[0]; //-- Attachment point. Main part
|
||||
v = a[1]; //-- Attachment axis. Main part
|
||||
roll = a[2]; //-- Rolling angle
|
||||
|
||||
pos2 = b[0]; //-- Attachment point. Attachable part
|
||||
vref = b[1]; //-- Atachment axis. Attachable part
|
||||
//-- The rolling angle of the attachable part is not used
|
||||
|
||||
//-------- Calculations for the "orientate operator"------
|
||||
//-- Calculate the rotation axis
|
||||
raxis = cross(vref,v);
|
||||
|
||||
//-- Calculate the angle between the vectors
|
||||
ang = anglev(vref,v);
|
||||
//--------------------------------------------------------.-
|
||||
|
||||
//-- Apply the transformations to the child ---------------------------
|
||||
|
||||
//-- Place the attachable part on the main part attachment point
|
||||
translate(pos1)
|
||||
//-- Orientate operator. Apply the orientation so that
|
||||
//-- both attachment axis are paralell. Also apply the roll angle
|
||||
rotate(a=roll, v=v) rotate(a=ang, v=raxis)
|
||||
//-- Attachable part to the origin
|
||||
translate(-pos2)
|
||||
child(0);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
//--- An example of the attach operator
|
||||
//---
|
||||
//--- There are two parts: the main body and an arm
|
||||
//--- They both are cubes (for simplicity)
|
||||
//---
|
||||
//-- In the main body there are 2 connectors defined, so that
|
||||
//-- the arm can be attached to any of them (or both if you like)
|
||||
//------------------------------------------------------------------
|
||||
|
||||
//-- In the debug mode the connectors and additional information
|
||||
//-- are shown
|
||||
debug=true;
|
||||
|
||||
//-- Define the Main part: A cube
|
||||
//-- Two attachment points are defined: one on the top, another in the
|
||||
//--- left side
|
||||
size = [10,10,10];
|
||||
|
||||
//-- Connectors defined:
|
||||
|
||||
//-- Att. point Att. Axis Roll
|
||||
c1 = [ [0,0,size[2]/2], [0,0,1], 20]; //-- Connector on the top
|
||||
c2 = [ [-size[0]/2,0,0], [-1,0,0], 90]; //-- Connector on the left
|
||||
|
||||
|
||||
//-- Draw the main part along with the connectors (for debugging)
|
||||
cube(size,center=true);
|
||||
|
||||
//-- In debug mode: Draw the main part connectors!
|
||||
if (debug) {
|
||||
connector(c1);
|
||||
connector(c2);
|
||||
}
|
||||
|
||||
//-- Define the Attachable part. It is another cube, with one connector
|
||||
asize = [5,20,3];
|
||||
a = [ [0,asize[1]/2-3,-asize[2]/2], [0,0,1], 0 ];
|
||||
|
||||
|
||||
//-- Do the attach!
|
||||
//-- Just change c1 by c2 to attach the part to the other
|
||||
//-- connector. Super-easy!! :-)
|
||||
//-- Modify the c1 and c2 roll angle for rotating the attachable
|
||||
//-- part to the desired orientation
|
||||
attach(c1,a)
|
||||
//-- This is the attachable part!
|
||||
union() {
|
||||
cube(asize,center=true); //-- The part
|
||||
|
||||
//-- In debug mode show additional info:
|
||||
if (debug) {
|
||||
frame(l=10); //-- The part frame of reference.
|
||||
connector(a); //-- Show the part connector
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// Bevel edge cube.
|
||||
// (c) Juan Gonzalez-Gomez (Obijuan), Sep-2012
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//----------------- IMPLEMENTATION USING THE MINKOWSKI OPERATOR ----------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//-- Bevel Cube main function
|
||||
//-- Parameters:
|
||||
//-- * Size: Cube size
|
||||
//-- * cr : Corner radius (if cr==0, a standar cube is built)
|
||||
//-- * cres: Corner resolution (in points). cres=0 means flat corners
|
||||
//------------------------------------------------------------------------------
|
||||
module bcube(size,cr=0,cres=0)
|
||||
{
|
||||
//-- Internal cube size
|
||||
bsize = size - 2*[cr,cr,0];
|
||||
|
||||
//-- Get the (x,y) coorner coordinates in the 1st cuadrant
|
||||
x = bsize[0]/2;
|
||||
y = bsize[1]/2;
|
||||
|
||||
//-- A corner radius of 0 means a standar cube!
|
||||
if (cr==0)
|
||||
cube(bsize,center=true);
|
||||
else {
|
||||
|
||||
|
||||
//-- The height of minkowski object is double. So
|
||||
//-- we sould scale by 0.5
|
||||
scale([1,1,0.5])
|
||||
|
||||
//-- This translation is for centering the minkowski objet
|
||||
translate([-x, -y,0])
|
||||
|
||||
//-- Built the beveled cube with minkowski
|
||||
minkowski() {
|
||||
|
||||
//-- Internal cube
|
||||
cube(bsize,center=true);
|
||||
|
||||
//-- Cylinder in the corner (1st cuadrant)
|
||||
translate([x,y, 0])
|
||||
cylinder(r=cr, h=bsize[2],center=true, $fn=4*(cres+1));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-- Examples of use of the bcube() module
|
||||
|
||||
//-- Standar cube
|
||||
translate([-15,15,0])
|
||||
bcube([20,20,10]);
|
||||
|
||||
//-- Beveled cube (0 point resolution)
|
||||
translate([15,15,0])
|
||||
bcube([20,20,10],cr=4);
|
||||
|
||||
//-- Beveled cube (1 point resolution)
|
||||
translate([-15,-15,0])
|
||||
bcube([20,20,10],cr=4, cres=1);
|
||||
|
||||
//-- Beveled cube (4 points resolution)
|
||||
translate([15,-15,0])
|
||||
bcube([20,20,10],cr=4, cres=4);
|
||||
|
||||
|
|
@ -0,0 +1,485 @@
|
|||
//---------------------------------------------------------------
|
||||
//-- Openscad Bevel library
|
||||
//-- Bevel the edges or add buttress to your parts!
|
||||
//---------------------------------------------------------------
|
||||
//-- This is a component of the obiscad opescad tools by Obijuan
|
||||
//-- (C) Juan Gonzalez-Gomez (Obijuan)
|
||||
//-- Sep-2012
|
||||
//---------------------------------------------------------------
|
||||
//-- Released under the GPL license
|
||||
//---------------------------------------------------------------
|
||||
use <vector.scad>
|
||||
use <attach.scad>
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
//- Rotate a vector an angle teta around the axis given by the
|
||||
//-- unit vector k
|
||||
//-----------------------------------------------------------------
|
||||
function Rot_axis_ang(p,k,teta) =
|
||||
p*cos(teta) + cross(k,p*sin(teta)) + k*dot(k,p)*(1-cos(teta));
|
||||
|
||||
//-- Transformation defined by rotating vfrom vector to vto
|
||||
//-- It is applied to vector v
|
||||
//-- It returns the transformed vector
|
||||
function Tovector(vfrom, vto, v) =
|
||||
Rot_axis_ang(v, unitv(cross(vfrom,vto)), anglev(vfrom,vto));
|
||||
|
||||
//-- Auxiliary function for extending a vector of 3 components to 4
|
||||
function ev(v,c=0) = [v[0], v[1], v[2], c];
|
||||
|
||||
//-- Calculate the determinant of a matrix given by 3 row vectors
|
||||
function det(a,b,c) =
|
||||
a[0]*(b[1]*c[2]-b[2]*c[1])
|
||||
- a[1]*(b[0]*c[2]-b[2]*c[0])
|
||||
+ a[2]*(b[0]*c[1]-b[1]*c[0]);
|
||||
|
||||
|
||||
//-- Sign function. It only returns 2 values: -1 when x is negative,
|
||||
//-- or 1 when x=0 or x>0
|
||||
function sign2(x) = sign(x)+1 - abs(sign(x));
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
//-- Beveled concave corner
|
||||
//-- NOT AN INTERFACE MODULE (The user should call bconcave_corner instead)
|
||||
//--
|
||||
//-- Parameters:
|
||||
//-- * cr: Corner radius
|
||||
//-- * cres: Corner resolution
|
||||
//-- * l: Length
|
||||
//- * th: Thickness
|
||||
//--------------------------------------------------------------------
|
||||
module bconcave_corner_aux(cr,cres,l,th)
|
||||
{
|
||||
|
||||
//-- vector for translating the main cube
|
||||
//-- so that the top rigth corner is on the origin
|
||||
v1 = -[(cr+th)/2, (cr+th)/2, 0];
|
||||
|
||||
//-- The part frame of reference is on the
|
||||
//-- internal corner
|
||||
v2 = [cr,cr,0];
|
||||
|
||||
//-- Locate the frame of ref. in the internal
|
||||
//-- corner
|
||||
translate(v2)
|
||||
difference() {
|
||||
|
||||
//-- Main cube for doing the corner
|
||||
translate(v1)
|
||||
//color("yellow",0.5)
|
||||
cube([cr+th, cr+th, l],center=true);
|
||||
|
||||
//-- Cylinder used for beveling...
|
||||
cylinder(r=cr, h=l+1, center=true, $fn=4*(cres+1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-- API MODULE
|
||||
//--
|
||||
//-- Beveled concave corner
|
||||
//--
|
||||
//-- Parameters:
|
||||
//-- * cr: Corner radius
|
||||
//-- * cres: Corner resolution
|
||||
//-- * l: Length
|
||||
//- * th: Thickness
|
||||
//-- * ext_corner: Where the origin is locate. By default it is located
|
||||
//-- in the internal corner (concave zone). If true,
|
||||
//-- it will be in the external corner (convex zone)
|
||||
//----------------------------------------------------------------------------
|
||||
module bconcave_corner(cr=1,cres=4,th=1,l=10,ext_corner=false)
|
||||
{
|
||||
//-- Locate the origin in the exterior edge
|
||||
if (ext_corner==true)
|
||||
translate([th,th,0])
|
||||
bconcave_corner_aux(cr,cres,l,th);
|
||||
else
|
||||
//-- Locate the origin in the interior edge
|
||||
translate([0.01, 0.01,0])
|
||||
bconcave_corner_aux(cr,cres,l,th);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//-- Auxiliary module (NOT FOR THE USER!)
|
||||
//-- It is and standar "attach", particularized for placing concave
|
||||
//-- corners
|
||||
//----------------------------------------------------------------------
|
||||
module bconcave_corner_attach_final(
|
||||
cfrom, //-- Origin connector
|
||||
cto, //-- Target connector
|
||||
cr,
|
||||
cres,
|
||||
l,
|
||||
th,
|
||||
ext_corner)
|
||||
{
|
||||
|
||||
//-- This block represent an attach operation
|
||||
//-- It is equivalent to: attach(cto,cfrom)
|
||||
translate(cto[0])
|
||||
rotate(a=cto[2], v=cto[1])
|
||||
rotate(a=anglev(cfrom[1],cto[1]),
|
||||
v=cross(cfrom[1],cto[1]) )
|
||||
translate(-cfrom[0])
|
||||
|
||||
//-- Place the concave corner (along with some debug information)
|
||||
union() {
|
||||
//color("Blue")
|
||||
//connector(cfrom);
|
||||
//connector([cfrom[0],cnormal_v,0]);
|
||||
bconcave_corner(cr=cr,
|
||||
cres=cres,
|
||||
l=l,
|
||||
th=th,
|
||||
ext_corner=ext_corner);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//-- Auxiliary module (NOT FOR THE USER!)
|
||||
//-- It is the general module for performing the bconcave corner attach
|
||||
//-- All the parameters should be passed to it
|
||||
//--
|
||||
//-- External connectors are where de concave corner will be placed. They
|
||||
//-- are provided by the user
|
||||
//--
|
||||
//-- Internal connectors refers to the connectors of the concave corner
|
||||
//--
|
||||
//-- Then an attach between the internal and external connectors is done
|
||||
//-------------------------------------------------------------------------
|
||||
module bconcave_corner_attach_aux(
|
||||
|
||||
//-- External connectors
|
||||
edge_c,
|
||||
normal_c,
|
||||
|
||||
//-- Internal connectors
|
||||
iedge_c,
|
||||
inormal_c,
|
||||
|
||||
//-- Other params
|
||||
cr,
|
||||
cres,
|
||||
th,
|
||||
l,
|
||||
ext_corner)
|
||||
|
||||
{
|
||||
//-- Get the Corner vectors from the internal connectors
|
||||
cedge_v = iedge_c[1]; //-- Corner edge vector
|
||||
cnormal_v = inormal_c[1]; //-- Corner normal vector
|
||||
|
||||
//-- Get the vector paralell and normal to the edge
|
||||
//-- From the external connectors
|
||||
edge_v = edge_c[1]; //-- Edge verctor
|
||||
enormal_v = normal_c[1]; //-- Edge normal vector
|
||||
|
||||
//---------------------------------------------------------------
|
||||
//-- For doing a correct attach, first the roll angle for the
|
||||
//-- external connector should be calculated. It determines the
|
||||
//-- orientation of the concave corner around the edge vector
|
||||
//--
|
||||
//-- This orientation is calculated using the edge normal vectors
|
||||
//-- that bisec the corner
|
||||
//--
|
||||
//-- There are 2 different cases: depending on the relative angle
|
||||
//-- between the internal and external edges. They can be parallel
|
||||
//-- or not
|
||||
//-----------------------------------------------------------------
|
||||
//-- The roll angle has two components: the value and the sign
|
||||
|
||||
//-- Calculate the sign of the rotation (the sign of roll)
|
||||
s=sign2(det(cnormal_v,enormal_v,edge_v));
|
||||
|
||||
//-- Calculate the roll when the edges are paralell
|
||||
rollp = s*anglev(cnormal_v, enormal_v);
|
||||
|
||||
//-- Calculate the roll in the general case
|
||||
Tcnormal_v = Tovector(cedge_v, edge_v, cnormal_v);
|
||||
rollg=s*anglev(Tcnormal_v, enormal_v);
|
||||
|
||||
//-- For the paralell case... use rollp
|
||||
if (mod(cross(cedge_v,edge_v))==0) {
|
||||
//echo("Paralell");
|
||||
|
||||
//-- Place the concave bevel corner!
|
||||
bconcave_corner_attach_final(
|
||||
cfrom = [[0,0,0], cedge_v, 0],
|
||||
cto = [edge_c[0], edge_c[1], rollp],
|
||||
cr = cr,
|
||||
cres = cres,
|
||||
l = l,
|
||||
th = th,
|
||||
ext_corner = ext_corner);
|
||||
}
|
||||
|
||||
//-- For the general case, use rollg
|
||||
else {
|
||||
//echo("not paralell");
|
||||
|
||||
//-- Place the concave bevel corner!
|
||||
bconcave_corner_attach_final(
|
||||
cfrom = [[0,0,0], cedge_v, 0],
|
||||
cto = [edge_c[0], edge_c[1], rollg],
|
||||
cr = cr,
|
||||
cres = cres,
|
||||
l = l,
|
||||
th = th,
|
||||
ext_corner = ext_corner);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//-- API MODULE
|
||||
//--
|
||||
//-- Bevel an edge. A concave corner is located so that the calling
|
||||
//-- module can easily perform a difference() operation
|
||||
//--
|
||||
//-- Two connectors are needed:
|
||||
//-- * edge_c : Connector located on the edge, paralell to the edge
|
||||
//-- * normal_c : Connector located on the same point than edge_c
|
||||
//-- pointing to the internal corner part, in the direction
|
||||
//-- of the corner bisector
|
||||
//-- * cr : Corner radius
|
||||
//-- * cres : Corner resolution
|
||||
//-- * l : Corner length
|
||||
//--------------------------------------------------------------------------
|
||||
module bevel(
|
||||
edge_c,
|
||||
normal_c,
|
||||
cr=3,
|
||||
cres=3,
|
||||
l=5)
|
||||
{
|
||||
|
||||
//-- Call the general module with the correct internal connectors
|
||||
bconcave_corner_attach_aux(
|
||||
|
||||
//-- External connectors
|
||||
edge_c = edge_c,
|
||||
normal_c = normal_c,
|
||||
|
||||
//-- Internal connectors
|
||||
iedge_c = [[0,0,0], unitv([0,0,1]), 0],
|
||||
inormal_c = [[0,0,0], [-1,-1,0] , 0],
|
||||
|
||||
//-- The other params
|
||||
cr=cr,
|
||||
cres=cres,
|
||||
l=l,
|
||||
th=1,
|
||||
ext_corner=false);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//-- API MODULE
|
||||
//--
|
||||
//-- Attach a Beveled concave corner
|
||||
//-- Two connectors are needed:
|
||||
//-- * edge_c : Connector located on the edge, paralell to the edge
|
||||
//-- * normal_c : Connector located on the same point than edge_c
|
||||
//-- pointing to the internal corner part, in the direction
|
||||
//-- of the corner bisector
|
||||
//-- * cr : Corner radius
|
||||
//-- * cres : Corner resolution
|
||||
//-- * l : Corner length
|
||||
//-- * th : Corner thickness (not visible when ext_corner=false)
|
||||
//-- * ext_corner: If the exterior corner is used as a reference
|
||||
//--------------------------------------------------------------------------
|
||||
module bconcave_corner_attach(
|
||||
edge_c,
|
||||
normal_c,
|
||||
cr=3,
|
||||
cres=3,
|
||||
l=5,
|
||||
th=1,
|
||||
ext_corner=false)
|
||||
{
|
||||
|
||||
//-- Call the general module with the correct internal connectors
|
||||
bconcave_corner_attach_aux(
|
||||
|
||||
//-- External connectors
|
||||
edge_c = edge_c,
|
||||
normal_c = normal_c,
|
||||
|
||||
//-- Internal connectors
|
||||
iedge_c = [[0,0,0], unitv([0,0,1]), 0],
|
||||
inormal_c = [[0,0,0], [1,1,0] , 0],
|
||||
|
||||
//-- The other params
|
||||
cr=cr,
|
||||
cres=cres,
|
||||
l=l,
|
||||
th=th,
|
||||
ext_corner=ext_corner);
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------
|
||||
//--- TEST MODULES
|
||||
//-----------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
//-- Testing the Bevel operator... All the 12 edges of a cube
|
||||
//-- are beveled. All the cases are covered, so it is a good
|
||||
//-- test for finding bugs!
|
||||
//----------------------------------------------------------------
|
||||
module Test1_beveled_cube()
|
||||
{
|
||||
//-------- Main object
|
||||
size=[30,30,30];
|
||||
|
||||
|
||||
//-- Define all the edges connectors
|
||||
ec1 = [[size[0]/2, 0,size[2]/2], [0,1,0], 0];
|
||||
en1 = [ec1[0], [1,0,1], 0];
|
||||
|
||||
ec2 = [[-size[0]/2, 0,size[2]/2], [0,1,0], 0];
|
||||
en2 = [ec2[0], [-1,0,1], 0];
|
||||
|
||||
ec3 = [[-size[0]/2, 0,-size[2]/2], [0,1,0], 0];
|
||||
en3 = [ec3[0], [-1,0,-1], 0];
|
||||
|
||||
ec4 = [[size[0]/2, 0,-size[2]/2], [0,1,0], 0];
|
||||
en4 = [ec4[0], [1,0,-1], 0];
|
||||
|
||||
ec5 = [[0, size[0]/2,size[2]/2], [1,0,0], 0];
|
||||
en5 = [ec5[0], [0,1,1], 0];
|
||||
|
||||
ec6 = [[0, -size[0]/2,size[2]/2], [1,0,0], 0];
|
||||
en6 = [ec6[0], [0,-1,1], 0];
|
||||
|
||||
ec7 = [[0, -size[0]/2,-size[2]/2], [1,0,0], 0];
|
||||
en7 = [ec7[0], [0,-1,-1], 0];
|
||||
|
||||
ec8 = [[0, size[0]/2,-size[2]/2], [1,0,0], 0];
|
||||
en8 = [ec8[0], [0,1,-1], 0];
|
||||
|
||||
ec9 = [[size[2]/2, size[0]/2,0 ], [0,0,1], 0];
|
||||
en9 = [ec9[0], [1,1,0], 0];
|
||||
|
||||
ec10 = [[size[2]/2, -size[0]/2,0 ], [0,0,1], 0];
|
||||
en10 = [ec10[0], [1,-1,0], 0];
|
||||
|
||||
ec11 = [[-size[2]/2, -size[0]/2,0 ], [0,0,1], 0];
|
||||
en11 = [ec11[0], [-1,-1,0], 0];
|
||||
|
||||
ec12 = [[-size[2]/2, size[0]/2,0 ], [0,0,1], 0];
|
||||
en12 = [ec12[0], [-1,1,0], 0];
|
||||
|
||||
|
||||
//-- for Debuging... Show a specefic connector
|
||||
*connector(ec12);
|
||||
*connector(en12);
|
||||
|
||||
//-- Parameters for all the beveled edges
|
||||
//-- It can be changed for testing
|
||||
cr=2;
|
||||
cres=0;
|
||||
|
||||
//-- Remove from the main cube the concave corner parts
|
||||
difference() {
|
||||
|
||||
//-- Draw the main cube
|
||||
cube(size,center=true);
|
||||
|
||||
//-- Attach the concave corners for beveling!
|
||||
bevel(ec1,en1,cr=cr,cres=0, l=size[1]+2);
|
||||
bevel(ec2,en2,cr=cr,cres=0, l=size[1]+2);
|
||||
bevel(ec3,en3,cr=cr,cres=0, l=size[1]+2);
|
||||
bevel(ec4,en4,cr=cr,cres=0, l=size[1]+2);
|
||||
|
||||
bevel(ec5,en5,cr=cr,cres=0, l=size[0]+2);
|
||||
bevel(ec6,en6,cr=cr,cres=0, l=size[0]+2);
|
||||
bevel(ec7,en7,cr=cr,cres=0, l=size[0]+2);
|
||||
bevel(ec8,en8,cr=cr,cres=0, l=size[0]+2);
|
||||
|
||||
bevel(ec9,en9,cr=cr,cres=0, l=size[0]+2);
|
||||
bevel(ec10,en10,cr=cr,cres=0, l=size[0]+2);
|
||||
bevel(ec11,en11,cr=cr,cres=0, l=size[0]+2);
|
||||
bevel(ec12,en12,cr=cr,cres=0, l=size[0]+2);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
//-- Testing the bconcave_corner_attach operator
|
||||
//-- It is used for adding buttress between two ortogonal parts
|
||||
//----------------------------------------------------------------
|
||||
module Test2_buttress()
|
||||
{
|
||||
size=[30,30,30];
|
||||
th=3;
|
||||
l=2;
|
||||
cr = 6;
|
||||
|
||||
|
||||
//-- A cross. It divides the space in 4 quadrants
|
||||
difference() {
|
||||
cube(size,center=true);
|
||||
translate([size[0]/4 + th/2, 0, size[0]/4 + th/2])
|
||||
cube([size[0]/2, size[1]+2, size[2]/2],center=true);
|
||||
|
||||
translate([-size[0]/4 - th/2, 0, size[0]/4 + th/2])
|
||||
cube([size[0]/2, size[1]+2, size[2]/2],center=true);
|
||||
|
||||
translate([-size[0]/4 - th/2, 0, -size[0]/4 - th/2])
|
||||
cube([size[0]/2, size[1]+2, size[2]/2],center=true);
|
||||
|
||||
translate([size[0]/4 + th/2, 0, -size[0]/4 - th/2])
|
||||
cube([size[0]/2, size[1]+2, size[2]/2],center=true);
|
||||
}
|
||||
|
||||
ec1 = [[th/2, size[1]/2-l/2, th/2], [0,1,0], 0];
|
||||
en1 = [ec1[0],[1,0,1],0];
|
||||
|
||||
ec2 = [[th/2, -size[1]/2+l/2, th/2], [0,1,0], 0];
|
||||
en2 = [ec2[0],[1,0,1],0];
|
||||
|
||||
ec3 = [[-th/2, 0, th/2], [0,1,0], 0];
|
||||
en3 = [ec3[0],[-1,0,1],0];
|
||||
|
||||
ec4 = [[-th/2, 0, -th/2], [0,1,0], 0];
|
||||
en4 = [ec4[0],[-1,0,-1],0];
|
||||
|
||||
ec5 = [[th/2, 0, -th/2], [0,1,0], 0];
|
||||
en5 = [ec5[0],[1,0,-1],0];
|
||||
|
||||
*connector(ec5);
|
||||
*connector(en5);
|
||||
|
||||
//-- quadrant 1: two buttress
|
||||
bconcave_corner_attach(ec1,en1,cr, l=l, cres=0);
|
||||
bconcave_corner_attach(ec2,en2,cr, l=l, cres=0);
|
||||
|
||||
//-- quadrant 2: one bit buttress
|
||||
bconcave_corner_attach(ec3,en3,cr=3, l=size[1], cres=0);
|
||||
|
||||
//-- quadrant 3: a Rounded buttress
|
||||
bconcave_corner_attach(ec4,en4,cr=8, l=size[1], cres=5);
|
||||
|
||||
//-- Quadrant 4: A rounded buttress in the middle
|
||||
bconcave_corner_attach(ec5,en5,cr=8, l=size[1]/3, cres=5);
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//-- TESTS
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-- example 1: A beveled concave corner
|
||||
bconcave_corner(cr=15, cres=10, l=10, th=3, ext_corner=true);
|
||||
|
||||
//-- Example 2: Testing the bevel() operator
|
||||
//Test1_beveled_cube();
|
||||
|
||||
//-- Example 3: Testing the bconcave_corner_attach() operator
|
||||
//Test2_buttress();
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
//---------------------------------------------------------------
|
||||
//-- Utils. General utilities...
|
||||
//-- This is a component of the obiscad opescad tools by Obijuan
|
||||
//-- (C) Juan Gonzalez-Gomez (Obijuan)
|
||||
//-- Sep-2012
|
||||
//---------------------------------------------------------------
|
||||
//-- Released under the GPL license
|
||||
//---------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------
|
||||
//-- Functions for converting a scalar into a vector:
|
||||
//-----------------------------------------------------
|
||||
//-- The scalar is interpreted as the x coordinate
|
||||
function VX(x) = [x,0,0];
|
||||
|
||||
//-- The scalar is interpreted as the y coordinate
|
||||
function VY(y) = [0,y,0];
|
||||
|
||||
//-- The scalar is interpreted as the z coordinate
|
||||
function VZ(z) = [0,0,z];
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
//-- Definition for accessing vector componentes easily
|
||||
//--------------------------------------------------------
|
||||
X = 0;
|
||||
Y = 1;
|
||||
Z = 2;
|
||||
|
||||
|
|
@ -0,0 +1,345 @@
|
|||
//---------------------------------------------------------------
|
||||
//-- Openscad vector library
|
||||
//-- This is a component of the obiscad opescad tools by Obijuan
|
||||
//-- (C) Juan Gonzalez-Gomez (Obijuan)
|
||||
//-- Sep-2012
|
||||
//---------------------------------------------------------------
|
||||
//-- Released under the GPL license
|
||||
//---------------------------------------------------------------
|
||||
|
||||
//----------------------------------------
|
||||
//-- FUNCTIONS FOR WORKING WITH VECTORS
|
||||
//----------------------------------------
|
||||
|
||||
//-- Calculate the module of a vector
|
||||
function mod(v) = (sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]));
|
||||
|
||||
//-- Calculate the cros product of two vectors
|
||||
function cross(u,v) = [
|
||||
u[1]*v[2] - v[1]*u[2],
|
||||
-(u[0]*v[2] - v[0]*u[2]) ,
|
||||
u[0]*v[1] - v[0]*u[1]];
|
||||
|
||||
//-- Calculate the dot product of two vectors
|
||||
function dot(u,v) = u[0]*v[0]+u[1]*v[1]+u[2]*v[2];
|
||||
|
||||
//-- Return the unit vector of a vector
|
||||
function unitv(v) = v/mod(v);
|
||||
|
||||
//-- Return the angle between two vectors
|
||||
function anglev(u,v) = acos( dot(u,v) / (mod(u)*mod(v)) );
|
||||
|
||||
//-- Return a vector that is perpendicular
|
||||
function perpendicular(vec) = vec.x == 0 ? [1,0,0] : vec.y == 0 ? [0,1,0] : vec.z == 0 ? [0,0,1] : [-vec.y,vec.x,0];;
|
||||
|
||||
//----------------------------------------------------------
|
||||
//-- Draw a point in the position given by the vector p
|
||||
//----------------------------------------------------------
|
||||
module point(p)
|
||||
{
|
||||
translate(p)
|
||||
sphere(r=0.7,$fn=20);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//-- Draw a vector poiting to the z axis
|
||||
//-- This is an auxiliary module for implementing the vector module
|
||||
//--
|
||||
//-- Parameters:
|
||||
//-- l: total vector length (line + arrow)
|
||||
//-- l_arrow: Vector arrow length
|
||||
//-- mark: If true, a mark is draw in the vector head, for having
|
||||
//-- a visual reference of the rolling angle
|
||||
//------------------------------------------------------------------
|
||||
module vectorz(l=10, l_arrow=4, mark=false)
|
||||
{
|
||||
//-- vector body length (not including the arrow)
|
||||
lb = l - l_arrow;
|
||||
|
||||
//-- The vector is locatead at 0,0,0
|
||||
translate([0,0,lb/2])
|
||||
union() {
|
||||
|
||||
//-- Draw the arrow
|
||||
translate([0,0,lb/2])
|
||||
cylinder(r1=2/2, r2=0.2, h=l_arrow, $fn=20);
|
||||
|
||||
//-- Draw the mark
|
||||
if (mark) {
|
||||
translate([0,0,lb/2+l_arrow/2])
|
||||
translate([1,0,0])
|
||||
cube([2,0.3,l_arrow*0.8],center=true);
|
||||
}
|
||||
|
||||
//-- Draw the body
|
||||
cylinder(r=1/2, h=lb, center=true, $fn=20);
|
||||
}
|
||||
|
||||
//-- Draw a sphere in the vector base
|
||||
sphere(r=1/2, $fn=20);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
//-- ORIENTATE OPERATOR
|
||||
//--
|
||||
//-- Orientate an object to the direction given by the vector v
|
||||
//-- Parameters:
|
||||
//-- v : Target orientation
|
||||
//-- vref: Vector reference. It is the vector of the local frame
|
||||
//-- of the object that want to be poiting in the direction
|
||||
//-- of v
|
||||
//-- roll: Rotation of the object around the v axis
|
||||
//-------------------------------------------------------------------
|
||||
module orientate(v,vref=[0,0,1], roll=0)
|
||||
{
|
||||
//-- Calculate the rotation axis
|
||||
raxis = cross(vref,v);
|
||||
|
||||
//-- Calculate the angle between the vectors
|
||||
ang = anglev(vref,v);
|
||||
|
||||
//-- Rotate the child!
|
||||
rotate(a=roll, v=v)
|
||||
rotate(a=ang, v=raxis)
|
||||
child(0);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//-- Draw a vector
|
||||
//--
|
||||
//-- There are two modes of drawing the vector
|
||||
//-- * Mode 1: Given by a cartesian point(x,y,z). A vector from the origin
|
||||
//-- to the end (x,y,z) is drawn. The l parameter (length) must
|
||||
//-- be 0 (l=0)
|
||||
//-- * Mode 2: Give by direction and length
|
||||
//-- A vector of length l pointing to the direction given by
|
||||
//-- v is drawn
|
||||
//---------------------------------------------------------------------------
|
||||
//-- Parameters:
|
||||
//-- v: Vector cartesian coordinates
|
||||
//-- l: total vector length (line + arrow)
|
||||
//-- l_arrow: Vector arrow length
|
||||
// mark: If true, a mark is draw in the vector head, for having
|
||||
//-- a visual reference of the rolling angle
|
||||
//---------------------------------------------------------------------------
|
||||
module vector(v,l=0, l_arrow=4, mark=false)
|
||||
{
|
||||
//-- Get the vector length from the coordinates
|
||||
mod = mod(v);
|
||||
|
||||
//-- The vector is very easy implemented by means of the orientate
|
||||
//-- operator:
|
||||
//-- orientate(v) vectorz(l=mod, l_arrow=l_arrow)
|
||||
//-- BUT... in OPENSCAD 2012.02.22 the recursion does not
|
||||
//-- not work, so that if the user use the orientate operator
|
||||
//-- on a vector, openscad will ignore it..
|
||||
//-- The solution at the moment (I hope the openscad developers
|
||||
//-- implement the recursion in the near future...)
|
||||
//-- is to repite the orientate operation in this module
|
||||
|
||||
//---- SAME CALCULATIONS THAN THE ORIENTATE OPERATOR!
|
||||
//-- Calculate the rotation axis
|
||||
|
||||
vref = [0,0,1];
|
||||
raxis = cross(vref,v);
|
||||
|
||||
//-- Calculate the angle between the vectors
|
||||
ang = anglev(vref,v);
|
||||
|
||||
//-- orientate the vector
|
||||
//-- Draw the vector. The vector length is given either
|
||||
//--- by the mod variable (when l=0) or by l (when l!=0)
|
||||
if (l==0)
|
||||
rotate(a=ang, v=raxis)
|
||||
vectorz(l=mod, l_arrow=l_arrow, mark=mark);
|
||||
else
|
||||
rotate(a=ang, v=raxis)
|
||||
vectorz(l=l, l_arrow=l_arrow, mark=mark);
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
//-- Draw a Frame of reference
|
||||
//-- Parameters:
|
||||
//-- l: length of the Unit vectors
|
||||
//-----------------------------------------------------
|
||||
module frame(l=10, l_arrow=4)
|
||||
{
|
||||
|
||||
//-- Z unit vector
|
||||
color("Blue")
|
||||
vector([0,0,l], l_arrow=l_arrow);
|
||||
|
||||
//-- X unit vector
|
||||
color("Red")
|
||||
vector([l,0,0], l_arrow=l_arrow );
|
||||
|
||||
//-- Y unit vector
|
||||
color("Green")
|
||||
vector([0,l,0],l_arrow=l_arrow);
|
||||
|
||||
//-- Origin
|
||||
color("Gray")
|
||||
sphere(r=1, $fn=20);
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
//-- Modules for testings and examples
|
||||
//-- Testing that the vector library is working ok
|
||||
//--------------------------------------------------
|
||||
|
||||
//-- 22 vectors in total are drawn, poiting to different directions
|
||||
module Test_vectors1()
|
||||
{
|
||||
|
||||
a = 20;
|
||||
k = 1;
|
||||
|
||||
//-- Add a frame of reference (in the origin)
|
||||
frame(l=a);
|
||||
|
||||
//-- Negative vectors, pointing towards the three axis: -x, -y, -z
|
||||
color("Red") vector([-a, 0, 0]);
|
||||
color("Green") vector([0, -a, 0]);
|
||||
color("Blue") vector([0, 0, -a]);
|
||||
|
||||
//-- It is *not* has been implemented using a for loop on purpose
|
||||
//-- This way, individual vectors can be commented out or highlighted
|
||||
|
||||
//-- vectors with positive z
|
||||
vector([a, a, a*k]);
|
||||
vector([0, a, a*k]);
|
||||
vector([-a, a, a*k]);
|
||||
vector([-a, 0, a*k]);
|
||||
|
||||
vector([-a, -a, a*k]);
|
||||
vector([0, -a, a*k]);
|
||||
vector([a, -a, a*k]);
|
||||
vector([a, 0, a*k]);
|
||||
|
||||
|
||||
//-- Vectors with negative z
|
||||
vector([a, a, -a*k]);
|
||||
vector([0, a, -a*k]);
|
||||
vector([-a, a, -a*k]);
|
||||
vector([-a, 0, -a*k]);
|
||||
|
||||
vector([-a, -a, -a*k]);
|
||||
vector([0, -a, -a*k]);
|
||||
vector([a, -a, -a*k]);
|
||||
vector([a, 0, -a*k]);
|
||||
}
|
||||
|
||||
//--- Another test...
|
||||
module Test_vectors2()
|
||||
{
|
||||
|
||||
//-- Add the vector into the vector table
|
||||
//-- This vectors are taken as directions
|
||||
//-- All the vectors will be drawn with the same length (l)
|
||||
vector_table = [
|
||||
[1, 1, 1],
|
||||
[0, 1, 1],
|
||||
[-1, 1, 1],
|
||||
[-1, 0, 1],
|
||||
[-1, -1, 1],
|
||||
[0, -1, 1],
|
||||
[1, -1, 1],
|
||||
[1, 0, 1],
|
||||
|
||||
[1, 1, -1],
|
||||
[0, 1, -1],
|
||||
[-1, 1, -1],
|
||||
[-1, 0, -1],
|
||||
[-1, -1, -1],
|
||||
[0, -1, -1],
|
||||
[1, -1, -1],
|
||||
[1, 0, -1],
|
||||
];
|
||||
|
||||
//-- Vector length
|
||||
l=20;
|
||||
|
||||
frame(l=10);
|
||||
|
||||
//-- Draw all the vector given in the table
|
||||
//-- The vectors point to the direction given in the table
|
||||
//-- They all are drawn with a length equal to l
|
||||
for (v=vector_table) {
|
||||
//-- Vector given by direction and length
|
||||
vector(v,l=l);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-- Test the cross product and the angle
|
||||
//-- between vectors
|
||||
module Test_vector3()
|
||||
{
|
||||
//-- Start with 2 unit vectors
|
||||
v=unitv([1,1,1]);
|
||||
u=unitv([0,1,0]);
|
||||
|
||||
//-- Draw the vector in different colors
|
||||
//-- Increase the length for drawing
|
||||
color("Red") vector(v*20);
|
||||
color("blue") vector(u*20);
|
||||
|
||||
//-- Get the cross product
|
||||
w = cross(v,u);
|
||||
vector(w*20);
|
||||
|
||||
//-- The cross product is NOT conmutative...
|
||||
//-- change the order of v and u
|
||||
w2 = cross(u,v);
|
||||
vector(w2*20);
|
||||
|
||||
//-- w should be perpendicular to v and u
|
||||
//-- Calculate the angles between them:
|
||||
echo("U , V: ", anglev(u,v));
|
||||
echo("W , U: ", anglev(w,u));
|
||||
echo("W , V: ", anglev(w,v));
|
||||
|
||||
}
|
||||
|
||||
//-- Test the orientate operator
|
||||
module Test_vector4()
|
||||
{
|
||||
o = [10,10,10];
|
||||
v = [-10,10,10];
|
||||
|
||||
color("Red") vector(o);
|
||||
color("Blue") vector(v);
|
||||
|
||||
//-- Orientate the vector o in the direction of v
|
||||
orientate(v,o)
|
||||
vector(o);
|
||||
|
||||
//-- Inverse operation: orientate the v vector in the direction
|
||||
//-- of o
|
||||
orientate(o,v)
|
||||
vector(v);
|
||||
|
||||
//-- Example of orientation of a cube
|
||||
orientate(o,vref=[10,-2,5],roll=0)
|
||||
cube([10,2,5],center=true);
|
||||
|
||||
vector([10,-2,5]);
|
||||
|
||||
}
|
||||
|
||||
//-------- Perform tests......
|
||||
|
||||
Test_vector4();
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Test_vectors1();
|
||||
|
||||
|
||||
translate([60,0,0])
|
||||
Test_vectors2();
|
||||
*/
|
||||
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
// This file is part of Cyclone PCB Factory: an open-source 3D printable CNC machine for PCB manufacture
|
||||
// http://reprap.org/wiki/Cyclone_PCB_Factory
|
||||
// Original author: Carlosgs (http://carlosgs.es)
|
||||
// License: Attribution - Share Alike - Creative Commons (http://creativecommons.org/licenses/by-sa/3.0/)
|
||||
// Designed with http://www.openscad.org/
|
||||
|
||||
use <obiscad/bcube.scad>
|
||||
|
||||
$render_standard_parts = false;
|
||||
|
||||
module renderStandardPart() {
|
||||
if($render_standard_parts) children();
|
||||
else %children();
|
||||
}
|
||||
|
||||
module standard_paperSheet_A4(t=0.05) {
|
||||
renderStandardPart()
|
||||
translate([0,0,t/2])
|
||||
color("white") cube([297,210,t], center=true);
|
||||
}
|
||||
|
||||
module standard_rod(diam=8, length=10, threaded=true, center=false, $fn=18) {
|
||||
renderStandardPart()
|
||||
if(threaded) {
|
||||
color("black") rotate([-90,0,0]) cylinder(r=diam/2, h=length, center=center);
|
||||
} else {
|
||||
color("grey") rotate([-90,0,0]) cylinder(r=diam/2, h=length, center=center);
|
||||
}
|
||||
}
|
||||
|
||||
module rubberFoot(diam=40, thickness=8) {
|
||||
renderStandardPart()
|
||||
color("black")
|
||||
translate([0,0,-thickness])
|
||||
cylinder(r=diam/2, h=thickness);
|
||||
}
|
||||
|
||||
|
||||
module beveledBase(size=[100,200,10], radius=10, res=15) {
|
||||
renderStandardPart()
|
||||
color("brown")
|
||||
translate([0,0,-size.z/2])
|
||||
bcube(size, cr=radius, cres=res);
|
||||
}
|
||||
|
Loading…
Reference in New Issue