User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
design_guide_3d_primitives [2018/02/11 12:05]
z3dev [Sphere]
design_guide_3d_primitives [2018/04/14 03:12] (current)
z3dev [3D Primitives]
Line 1: Line 1:
 ===== 3D Primitives ===== ===== 3D Primitives =====
  
-Introduction+‘3D’ stands for three (3) dimensional. A 3D primitive is any shape that has three dimensions, which are often called width, depth, and height (or X, Y, Z.) 3D shapes have a known volume if closed. 
 + 
 +{{ :​wiki:​mathisfun-3d.svg?​nolink&​145 |}} 
 + 
 +The mathematical study of 3D shapes and dimensions is called [[https://​simple.m.wikipedia.org/​wiki/​Solid_geometry|solid geometry]].
  
 ==== Resolution of Shapes ==== ==== Resolution of Shapes ====
Line 12: Line 16:
  
 If the ''​resolution''​ option is omitted, the following resolution is used. If the ''​resolution''​ option is omitted, the following resolution is used.
-  * CSG.defaultResolution3D+  * CSG.defaultResolution3D ​= 12
  
 OpenSCAD like functions support the ''​fn''​ parameter, which is the same as ''​resolution''​. OpenSCAD like functions support the ''​fn''​ parameter, which is the same as ''​resolution''​.
  
-==== Cube ==== +{{page>design_guide_cube}}
- +
-Cubes or rounded cubes are created by specifying one or more radius values. +
- +
-<code javascript>​ +
-cube(1); +
-cube({size: 1}); +
-cube({size: [1,​2,​3]});​ +
-cube({size: 1, center: true}); // default center:​false +
-cube({size: 1, center: [false,​false,​false]});​ // individual axis center true or false +
-cube({size: [1,2,3], round: true}); +
-</code> +
- +
-Also, using CSG library directly is possible. TO BE DECOMMISSIONED +
- +
-<code javascript>​ +
-CSG.cube({ +
-    center: [0, 0, 0], +
-    radius: [1, 1, 1] +
-}); +
- +
-CSG.cube({ // define two opposite corners +
-    corner1: [4, 4, 4], +
-    corner2: [5, 4, 2] +
-}); +
- +
-CSG.roundedCube({ // rounded cube +
-    center: [0, 0, 0], +
-    radius: 1, +
-    roundradius:​ 0.9, +
-    resolution: 8, +
-}); +
-</​code>​ +
- +
-==== Sphere ==== +
- +
-Spheres can be created like this: +
-<code javascript>​ +
-sphere(1);​ +
-sphere({r: 2});                    // Note: center:true is default (unlike other primitives, as OpenSCAD) +
-sphere({r: 2, center: true}); ​    // Note: OpenSCAD doesn'​t support center for sphere but we do +
-sphere({r: 2, center: [false, false, true]}); // individual axis center  +
-sphere({r: 10, fn: 100 }); +
-sphere({r: 10, fn: 100, type: '​geodesic'​}); ​ // geodesic approach (icosahedron further triangulated) +
- +
-CSG.sphere({ +
-  center: [0, 0, 0], +
-  radius: 2,                      // must be scalar +
-  resolution: 128 +
-}); +
-</​code>​ +
- +
-In case of ``type: '​geodesic'​`` the fn tries to match the non-geodesic fn, yet, actually changes in steps of 6 (e.g. fn=6..11 is the same), fn = 1 reveals the base form: the icosahedron.+
  
-==== Cylinder ====+{{page>​design_guide_sphere}}
  
-Cylinders and cones can be created like this:+{{page>​design_guide_cylinder}}
  
-<code javascript>​ +{{page>​design_guide_torus}}
-cylinder({r: 1, h: 10});                 // openscad like +
-cylinder({d: 1, h: 10}); +
-cylinder({r:​ 1, h: 10, center: true}); ​  // default: center:​false +
-cylinder({r:​ 1, h: 10, center: [true, true, false]}); ​ // individual x,y,z center flags +
-cylinder({r:​ 1, h: 10, round: true}); +
-cylinder({r1:​ 3, r2: 0, h: 10}); +
-cylinder({d1:​ 1, d2: 0.5, h: 10}); +
-cylinder({start:​ [0,0,0], end: [0,0,10], r1: 1, r2: 2, fn: 50});+
  
-CSG.cylinder(                     //​using the CSG primitives +{{page>​design_guide_polyhedron}}
-  start: [0, -1, 0], +
-  end: [0, 1, 0], +
-  radius: 1,                        // true cylinder +
-  resolution: 16 +
-}); +
-CSG.cylinder({ +
-  start: [0, -1, 0], +
-  end: [0, 1, 0], +
-  radiusStart:​ 1,                   // start- and end radius defined, partial cones +
-  radiusEnd: 2, +
-  resolution: 16 +
-}); +
-CSG.roundedCylinder({ ​              // and its rounded version +
-  start: [0, -1, 0], +
-  end: [0, 1, 0], +
-  radius: 1, +
-  resolution: 16 +
-}); +
-</​code>​+