omdl  v0.9.5
OpenSCAD Mechanical Design Library
radial_ball.scad
Go to the documentation of this file.
1 //! Radial ball bearing model.
2 /***************************************************************************//**
3  \file
4  \author Roy Allen Sutton
5  \date 2024
6 
7  \copyright
8 
9  This file is part of [omdl] (https://github.com/royasutton/omdl),
10  an OpenSCAD mechanical design library.
11 
12  The \em omdl is free software; you can redistribute it and/or modify
13  it under the terms of the [GNU Lesser General Public License]
14  (http://www.gnu.org/licenses/lgpl.html) as published by the Free
15  Software Foundation; either version 2.1 of the License, or (at
16  your option) any later version.
17 
18  The \em omdl is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  Lesser General Public License for more details.
22 
23  You should have received a copy of the GNU Lesser General Public
24  License along with the \em omdl; if not, write to the Free Software
25  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26  02110-1301, USA; or see <http://www.gnu.org/licenses/>.
27 
28  \details
29 
30  \amu_define group_name (radial ball)
31  \amu_define group_brief (Radial ball bearing model.)
32 
33  \amu_include (include/amu/pgid_path_pstem_pg.amu)
34 *******************************************************************************/
35 
36 //----------------------------------------------------------------------------//
37 // group and macros.
38 //----------------------------------------------------------------------------//
39 
40 /***************************************************************************//**
41  \amu_include (include/amu/group_in_parent_start.amu)
42  \amu_define includes_required_add
43  (
44  database/component/bearing/radial_ball.scad
45  )
46  \amu_include (include/amu/includes_required.amu)
47 *******************************************************************************/
48 
49 //----------------------------------------------------------------------------//
50 
51 //! Radial ball bearing model.
52 /***************************************************************************//**
53  \param n <string> the bearing model name (see: [database table]).
54  \param align <integer> model z-alignment; {0:bottom, 1:middle, 2:top}.
55  \param shell <boolean> render shell only.
56  \param wc <boolean> render with color.
57 
58  \details
59 
60  The available model names can be found in the [database table].
61 
62  \amu_define title (Bearing example)
63  \amu_define image_views (top right diag)
64  \amu_define image_size (sxga)
65 
66  \amu_include (include/amu/scope_diagrams_3d.amu)
67 
68  [database table]: \ref database_component_bearing_radial_ball
69 *******************************************************************************/
70 module radial_ball
71 (
72  n,
73  align = 1,
74  shell = false,
75  wc = true
76 )
77 {
79 
80  assert
81  (
82  ctable_exists(t, n),
83  str("model '", n, "' is undefined in table.")
84  );
85 
86  id = ctable_get(t, n, "id");
87  od = ctable_get(t, n, "od");
88  b = ctable_get(t, n, "b");
89 
90  // feature decorations
91  idr = id * 1.30; // bore rim
92  odr = od * 0.92; // outer rim
93  odc = od * 0.85; // outer clip rim
94  ifw = b * 0.95; // bearing cover width
95  ifc = b * 0.88; // bearing cover clip width 1
96  ifd = b * 0.80; // bearing cover clip width 2
97 
98  translate( select_ci( [ [0,0,+b/2], origin3d, [0,0,-b/2]], align, false ) )
99  if (shell == true)
100  {
101  color("silver")
102  cylinder(d=od, h=b, center=true);
103  }
104  else
105  {
106  difference()
107  {
108  union()
109  {
110  color(wc?"silver":undef) // outer diameter
111  difference()
112  {
113  cylinder(d=od, h=b, center=true);
114  cylinder(d=odr, h=b+eps*2, center=true);
115  }
116 
117  color(wc?"gray":undef) // clip rim
118  cylinder(d=odr, h=ifd, center=true);
119 
120  color(wc?"dimgray":undef) // cover
121  cylinder(d=odc, h=ifw, center=true);
122 
123  color(wc?"silver":undef) // bore rim
124  cylinder(d=idr, h=b, center=true);
125 
126  color(wc?"darkgray":undef) // cover clips
127  difference ()
128  {
129  cylinder(d=odr, h=ifc, center=true);
130  cylinder(d=odc, h=ifc+eps*4, center=true);
131  for (i = [0:6])
132  rotate([0, 0, 30*i])
133  cube([odr, (od-odr)/3, ifc+eps*4], center=true);
134  }
135  }
136 
137  cylinder(d=id, h=b+eps*2, center=true); // inner bore
138  }
139  }
140 }
141 
142 //! @}
143 //! @}
144 
145 
146 //----------------------------------------------------------------------------//
147 // openscad-amu auxiliary scripts
148 //----------------------------------------------------------------------------//
149 
150 /*
151 BEGIN_SCOPE example;
152  BEGIN_OPENSCAD;
153  include <omdl-base.scad>;
154  include <database/component/bearing/radial_ball.scad>;
155  include <models/3d/bearing/radial_ball.scad>;
156 
157  radial_ball("608");
158 
159  // end_include
160  END_OPENSCAD;
161 
162  BEGIN_MFSCRIPT;
163  include --path "${INCLUDE_PATH}" {var_init,var_gen_png2eps}.mfs;
164  table_unset_all sizes;
165 
166  images name "sizes" types "sxga";
167  views name "views" views "top right diag";
168 
169  variables set_opts_combine "sizes views";
170  variables add_opts "--viewall --autocenter --view=axes";
171 
172  include --path "${INCLUDE_PATH}" scr_make_mf.mfs;
173  END_MFSCRIPT;
174 END_SCOPE;
175 */
176 
177 //----------------------------------------------------------------------------//
178 // end of file
179 //----------------------------------------------------------------------------//
origin3d
<point-3d> The origin point coordinate in 3-dimensional Euclidean space.
Definition: constants.scad:425
eps
<decimal> Epsilon, small distance to deal with overlapping shapes.
Definition: constants.scad:195
dtc_bearing_radial_ball
dtr_bearing_radial_ball
function select_ci(v, i, l=true)
Select specified element from list or return a default.
function ctable_exists(t, ri, ci)
Test the existence of a table row identifier, table column identifier, or both.
function ctable_get(t, ri, ci)
Get a row, a column, or a specific cell value from a table.
module radial_ball(n, align=1, shell=false, wc=true)
Radial ball bearing model.