Increased OpenScad default fragment resolution
							parent
							
								
									98781246c3
								
							
						
					
					
						commit
						0d1c4b6346
					
				| 
						 | 
				
			
			@ -4,6 +4,9 @@
 | 
			
		|||
// License: CC BY-SA 4.0 (Attribution-ShareAlike 4.0 International, http://creativecommons.org/licenses/by-sa/4.0/)
 | 
			
		||||
// Designed with http://www.openscad.org/
 | 
			
		||||
 | 
			
		||||
// Increase the resolution of default shapes
 | 
			
		||||
$fa = 5; // Minimum angle for fragments [degrees]
 | 
			
		||||
$fs = 0.5; // Minimum fragment size [mm]
 | 
			
		||||
 | 
			
		||||
// Load necessary libraries
 | 
			
		||||
use <libs/obiscad/vector.scad>
 | 
			
		||||
| 
						 | 
				
			
			@ -232,5 +235,5 @@ translate([0,-axes_Ysmooth_rodLen/2+axes_Ycarriage_pos,axes_Y_threaded_height])
 | 
			
		|||
	Cyclone_Y_carriage();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
hole_for_screw(size=3,length=20,nutDepth=0,nutAddedLen=0,captiveLen=10);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,6 +4,10 @@
 | 
			
		|||
// License: CC BY-SA 4.0 (Attribution-ShareAlike 4.0 International, http://creativecommons.org/licenses/by-sa/4.0/)
 | 
			
		||||
// Designed with http://www.openscad.org/
 | 
			
		||||
 | 
			
		||||
module mirrorOrNot(mirrorPart=false, axes=[-1,1,1]) {
 | 
			
		||||
	if(mirrorPart) scale(axes) children();
 | 
			
		||||
	else children();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module Cyclone_Y_frontFrame() {
 | 
			
		||||
	color("lightred")
 | 
			
		||||
| 
						 | 
				
			
			@ -17,15 +21,19 @@ module Cyclone_Y_backFrame() {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
module Cyclone_Y_rightSmoothRodIdler() {
 | 
			
		||||
module Cyclone_Y_rightSmoothRodIdler(mirrorLogo = false) {
 | 
			
		||||
	color("lightcyan")
 | 
			
		||||
		translate([-5,0,-axes_Yreference_height]) {
 | 
			
		||||
			cube([20,10,axes_Yreference_height+5]);
 | 
			
		||||
		}
 | 
			
		||||
	translate([0,-10,0]) rotate([90,0,0]) linear_extrude(height=10, center = true) {
 | 
			
		||||
		if(mirrorLogo) scale([-1,1]) import("dxf/CycloneLogo.dxf");
 | 
			
		||||
		else import("dxf/CycloneLogo.dxf");
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
module Cyclone_Y_leftSmoothRodIdler() {
 | 
			
		||||
	scale([-1,1,1]) Cyclone_Y_rightSmoothRodIdler();
 | 
			
		||||
	scale([-1,1,1]) Cyclone_Y_rightSmoothRodIdler(mirrorLogo = true);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,99 @@
 | 
			
		|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
 | 
			
		||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
 | 
			
		||||
 | 
			
		||||
<svg
 | 
			
		||||
   xmlns:dc="http://purl.org/dc/elements/1.1/"
 | 
			
		||||
   xmlns:cc="http://creativecommons.org/ns#"
 | 
			
		||||
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 | 
			
		||||
   xmlns:svg="http://www.w3.org/2000/svg"
 | 
			
		||||
   xmlns="http://www.w3.org/2000/svg"
 | 
			
		||||
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
 | 
			
		||||
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
 | 
			
		||||
   width="178.17004"
 | 
			
		||||
   height="173.37346"
 | 
			
		||||
   id="svg3064"
 | 
			
		||||
   version="1.1"
 | 
			
		||||
   inkscape:version="0.48.4 r9939"
 | 
			
		||||
   sodipodi:docname="CycloneLogo.svg">
 | 
			
		||||
  <defs
 | 
			
		||||
     id="defs3" />
 | 
			
		||||
  <sodipodi:namedview
 | 
			
		||||
     inkscape:document-units="mm"
 | 
			
		||||
     id="base"
 | 
			
		||||
     pagecolor="#ffffff"
 | 
			
		||||
     bordercolor="#666666"
 | 
			
		||||
     borderopacity="1.0"
 | 
			
		||||
     inkscape:pageopacity="0.0"
 | 
			
		||||
     inkscape:pageshadow="2"
 | 
			
		||||
     inkscape:zoom="2.8284271"
 | 
			
		||||
     inkscape:cx="3.6162388"
 | 
			
		||||
     inkscape:cy="-7.7762638"
 | 
			
		||||
     inkscape:current-layer="layer1"
 | 
			
		||||
     showgrid="true"
 | 
			
		||||
     units="mm"
 | 
			
		||||
     inkscape:window-width="1920"
 | 
			
		||||
     inkscape:window-height="1025"
 | 
			
		||||
     inkscape:window-x="0"
 | 
			
		||||
     inkscape:window-y="27"
 | 
			
		||||
     inkscape:window-maximized="1"
 | 
			
		||||
     fit-margin-top="0"
 | 
			
		||||
     fit-margin-left="0"
 | 
			
		||||
     fit-margin-right="0"
 | 
			
		||||
     fit-margin-bottom="0">
 | 
			
		||||
    <inkscape:grid
 | 
			
		||||
       type="xygrid"
 | 
			
		||||
       id="grid3016"
 | 
			
		||||
       empspacing="5"
 | 
			
		||||
       visible="true"
 | 
			
		||||
       enabled="true"
 | 
			
		||||
       snapvisiblegridlinesonly="true" />
 | 
			
		||||
  </sodipodi:namedview>
 | 
			
		||||
  <metadata
 | 
			
		||||
     id="metadata4">
 | 
			
		||||
    <rdf:RDF>
 | 
			
		||||
      <cc:Work
 | 
			
		||||
         rdf:about="">
 | 
			
		||||
        <dc:format>image/svg+xml</dc:format>
 | 
			
		||||
        <dc:type
 | 
			
		||||
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
 | 
			
		||||
        <dc:title />
 | 
			
		||||
      </cc:Work>
 | 
			
		||||
    </rdf:RDF>
 | 
			
		||||
  </metadata>
 | 
			
		||||
  <g
 | 
			
		||||
     inkscape:label="logo"
 | 
			
		||||
     inkscape:groupmode="layer"
 | 
			
		||||
     id="layer1"
 | 
			
		||||
     transform="translate(-19.272178,-351.38974)">
 | 
			
		||||
    <path
 | 
			
		||||
       inkscape:connector-curvature="0"
 | 
			
		||||
       d="m -48.719241,437.84548 8.623657,0.15308 10.970922,1.04607 10.996436,1.68391 10.8433545,2.29624 10.511673,2.85754 10.0269065,3.36782 9.363559,3.80155 8.54711,4.20977 7.55208,4.56697 1.53083,1.07157 4.51594,1.88802 4.337341,2.24522 4.13323,2.55137 3.92912,2.85755 7.16937,6.53152 6.14882,7.5776 2.627919,4.10771 2.347261,4.33734 2.01559,4.51594 1.709419,4.72005 1.32672,4.84762 0.99504,5.0007 0.20411,1.78596 -45.59311,0 -0.892989,-1.68391 -2.347261,-2.80651 -2.80652,-2.34727 -3.24025,-1.73494 -3.57193,-1.12261 -3.82706,-0.3827 -3.82707,0.3827 -3.57192,1.12261 -3.240251,1.73494 -2.8065165,2.34727 -2.347268,2.80651 -1.734936,3.24025 -1.12260701,3.57193 -0.382706,3.82706 0.382706,3.82707 1.12260701,3.57193 1.734936,3.24025 2.347268,2.80651 2.8065165,2.32176 3.240251,1.76045 3.57192,1.09709 3.82707,0.38271 3.82706,-0.38271 3.57193,-1.09709 3.24025,-1.76045 2.80652,-2.32176 2.347261,-2.80651 1.734939,-3.24025 0.0765,-0.22963 44.802191,0 -0.99504,6.40396 -1.76045,6.60807 -2.39829,6.3019 -3.01063,5.99574 -3.57193,5.58752 -4.0822,5.17929 -4.56697,4.74556 0.10206,1.22466 0.5613,4.84762 0.969519,4.03117 1.505321,3.57193 2.143149,3.46988 3.112681,3.49538 3.64847,3.16371 6.09779,3.67398 7.11835,3.03613 8.368509,2.47486 9.848323,1.99006 1.91353,0.38272 -0.3827,0.33166 -6.02125,1.45428 -7.552082,0.96954 -16.992171,0 -10.99644,-1.04607 -10.99643,-1.68392 -10.84336,-2.29623 -10.51167,-2.85755 -10.02691,-3.36781 -9.36356,-3.80155 -8.5471095,-4.20977 -7.552079,-4.56697 -1.836991,-1.32671 -4.439398,-1.93905 -4.2863145,-2.24521 -7.934783,-5.43444 -7.041801,-6.53152 -6.046763,-7.52657 -4.898646,-8.41954 -1.990072,-4.49042 -1.658397,-4.66902 -1.326717,-4.79659 -0.94401,-4.97519 -0.586816,-5.07724 -0.20411,-5.20481 0.357194,-7.01629 1.071578,-6.81218 1.734936,-6.53152 2.372781,-6.25088 2.959597,-5.9447 3.495388,-5.56201 4.031176,-5.15378 4.490423,-4.72005 -0.127568,-1.55634 -0.561303,-4.84761 -0.995036,-4.03118 -1.505313,-3.57193 -2.143158,-3.46987 -3.112679,-3.49539 -3.622956,-3.18922 -6.097791,-3.67398 -7.118345,-3.01063 -8.368518,-2.47484 -9.848315,-1.99007 -1.913533,-0.38271 0.382707,-0.33167 6.02125,-1.45429 7.552075,-0.96953 8.368519,-0.17859 0,0"
 | 
			
		||||
       style="fill:#000000;stroke:#000000;stroke-width:0.28802216"
 | 
			
		||||
       id="path34" />
 | 
			
		||||
  </g>
 | 
			
		||||
  <g
 | 
			
		||||
     inkscape:groupmode="layer"
 | 
			
		||||
     id="layer3"
 | 
			
		||||
     inkscape:label="dot">
 | 
			
		||||
    <path
 | 
			
		||||
       style="fill:#000000"
 | 
			
		||||
       d="m 11.111679,173.37345 -0.225752,2.2394 -0.64746,2.08577 -1.0244855,1.88748 -1.35684,1.6445 -1.644493,1.35683 -1.88748,1.02449 -2.085781,0.64747 -2.239386,0.22574 -2.239394,-0.22574 -2.085773,-0.64747 -1.88748,-1.02449 -1.6445,-1.35683 -1.356833,-1.6445 -1.0244865,-1.88748 -0.647467,-2.08577 -0.225747,-2.2394 0.225747,-2.23938 0.647467,-2.08578 1.0244865,-1.88748 1.356833,-1.6445 1.6445,-1.35683 1.88748,-1.02449 2.085773,-0.64746 2.239394,-0.22575 2.239386,0.22575 2.085781,0.64746 1.88748,1.02449 1.644493,1.35683 1.35684,1.6445 1.0244855,1.88748 0.64746,2.08578 z"
 | 
			
		||||
       id="path2991"
 | 
			
		||||
       inkscape:connector-curvature="0"
 | 
			
		||||
       sodipodi:nodetypes="ccccccccccccccccccccccccccccccccc" />
 | 
			
		||||
  </g>
 | 
			
		||||
  <g
 | 
			
		||||
     inkscape:groupmode="layer"
 | 
			
		||||
     id="layer4"
 | 
			
		||||
     inkscape:label="Origin">
 | 
			
		||||
    <path
 | 
			
		||||
       sodipodi:type="arc"
 | 
			
		||||
       style="fill:#000000;fill-rule:evenodd;stroke:#ff0000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
 | 
			
		||||
       id="path3024"
 | 
			
		||||
       sodipodi:cx="0"
 | 
			
		||||
       sodipodi:cy="173.37346"
 | 
			
		||||
       sodipodi:rx="1"
 | 
			
		||||
       sodipodi:ry="1"
 | 
			
		||||
       d="m 1,173.37346 a 1,1 0 1 1 -2,0 1,1 0 1 1 2,0 z" />
 | 
			
		||||
  </g>
 | 
			
		||||
</svg>
 | 
			
		||||
| 
		 After Width: | Height: | Size: 5.4 KiB  | 
| 
						 | 
				
			
			@ -27,7 +27,7 @@ module hole_for_screw(size=3,length=20,nutDepth=5,nutAddedLen=0,captiveLen=0,tol
 | 
			
		|||
				}
 | 
			
		||||
	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);
 | 
			
		||||
			render() boltHole(size=size, length=length-2.6+0.5, tolerance=tolerance-0.1, proj=-1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
hole_for_screw(size=3,length=20,nutDepth=0,nutAddedLen=0,captiveLen=10);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,148 +0,0 @@
 | 
			
		|||
//---------------------------------------------------------------
 | 
			
		||||
//-- 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
 | 
			
		||||
    }
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1,70 +0,0 @@
 | 
			
		|||
//------------------------------------------------------------------------------
 | 
			
		||||
//  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);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1,485 +0,0 @@
 | 
			
		|||
//---------------------------------------------------------------
 | 
			
		||||
//-- 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();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1,30 +0,0 @@
 | 
			
		|||
//---------------------------------------------------------------
 | 
			
		||||
//-- 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;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1,344 +0,0 @@
 | 
			
		|||
//---------------------------------------------------------------
 | 
			
		||||
//-- 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
 | 
			
		||||
//---------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
obiscad_drawing_resolution = 6;
 | 
			
		||||
 | 
			
		||||
//----------------------------------------
 | 
			
		||||
//-- 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 vectores
 | 
			
		||||
function anglev(u,v) = acos( dot(u,v) / (mod(u)*mod(v)) );
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------
 | 
			
		||||
//--  Draw a point in the position given by the vector p  
 | 
			
		||||
//----------------------------------------------------------
 | 
			
		||||
module point(p)
 | 
			
		||||
{
 | 
			
		||||
  translate(p)
 | 
			
		||||
    sphere(r=0.7,$fn=obiscad_drawing_resolution);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//------------------------------------------------------------------
 | 
			
		||||
//-- 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=obiscad_drawing_resolution);
 | 
			
		||||
 | 
			
		||||
    //-- 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=obiscad_drawing_resolution);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //-- Draw a sphere in the vector base
 | 
			
		||||
  sphere(r=1/2, $fn=obiscad_drawing_resolution);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//-----------------------------------------------------------------
 | 
			
		||||
//-- 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=obiscad_drawing_resolution);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//--------------------------------------------------
 | 
			
		||||
//-- 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();
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -19,7 +19,7 @@ module standard_paperSheet_A4(t=0.05) {
 | 
			
		|||
			color("white") cube([297,210,t], center=true);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module standard_rod(diam=8, length=10, threaded=true, center=false, $fn=18) {
 | 
			
		||||
module standard_rod(diam=8, length=10, threaded=true, center=false) {
 | 
			
		||||
	renderStandardPart()
 | 
			
		||||
		if(threaded) {
 | 
			
		||||
			color("black") rotate([-90,0,0]) cylinder(r=diam/2, h=length, center=center);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue