forked from royasutton/omdl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainpage.scad
483 lines (375 loc) · 18.8 KB
/
mainpage.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
//! Library Documentation: main page.
/***************************************************************************//**
\file
\author Roy Allen Sutton
\date 2015-2019
\copyright
This file is part of [omdl] (https://github.com/royasutton/omdl),
an OpenSCAD mechanical design library.
The \em omdl is free software; you can redistribute it and/or modify
it under the terms of the [GNU Lesser General Public License]
(http://www.gnu.org/licenses/lgpl.html) as published by the Free
Software Foundation; either version 2.1 of the License, or (at
your option) any later version.
The \em omdl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the \em omdl; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA; or see <http://www.gnu.org/licenses/>.
*******************************************************************************/
//----------------------------------------------------------------------------//
// introduction.
//----------------------------------------------------------------------------//
/***************************************************************************//**
\mainpage omdl
\tableofcontents
\section introduction Introduction
[omdl] is an [OpenSCAD] mechanical design library that provides
open-source high-level design primitives with coherent
documentation generated by [Doxygen] using [openscad-amu].
With Doxygen, the code documentation is written within the code
itself, and is thus easy to keep current. Moreover, it provides a
standard way to both write and present OpenSCAD design
documentation, compilable to common output formats (html, pdf,
etc). With [omdl], all library primitives are \em parametric with
minimal, mostly zero, global variable dependencies and all library
API's include [markups] that describe its parameters, behavior, and
use.
[Validation] scripts are used to verify that the core operations
work as expected across evolving [OpenSCAD] versions (validation
performed when building the documentation). The library uses a
common set of conventions for specifying [data types] and is
divided into individual component modules of functionality,
organized into groups, that may be included as desired.
\section starting Getting Started
\b Example:
\dontinclude \amu_scope(index=2).scad
\skip include
\until valign="center" );
\amu_make png_files (append=quickstart extension=png)
\amu_make eps_files (append=quickstart extension=png2eps)
\amu_make stl_files (append=quickstart extension=stl)
\htmlonly
\amu_image_table
(
type=html columns=4 image_width="200" table_caption="Example Result"
cell_captions="Bottom^Diagonal^Right^Top"
cell_files="${png_files}"
cell_urls="${stl_files} ${stl_files} ${stl_files} ${stl_files}"
)
\endhtmlonly
\latexonly
\amu_image_table
(
type=latex columns=4 image_width="1.25in" table_caption="Example Result"
cell_captions="Bottom^Diagonal^Right^Top"
cell_files="${eps_files}"
)
\endlatexonly
\section contributing Contributing
[omdl] uses [git] for development tracking, and is hosted on
[GitHub] following the usual practice of [forking] and submitting
[pull requests] to the source repository.
As it is released under the [GNU Lesser General Public License],
any file you change should bear your copyright notice alongside the
original authors' copyright notices typically located at the top of
each file.
Ideas, requests, comments, contributions, and constructive
criticism are welcome.
\section support Support
In case you have any questions or would like to make feature
requests, you can contact the maintainer of the project or file an
[issue].
[GNU Lesser General Public License]: https://www.gnu.org/licenses/lgpl.html
[omdl]: https://royasutton.github.io/omdl
[omdl repository]: https://github.com/royasutton/omdl
[issue]: https://github.com/royasutton/omdl/issues
[Validation]: \ref validation
[data types]: \ref dt
[installation]: \ref install
[openscad-amu]: https://royasutton.github.io/openscad-amu
[Doxygen]: http://www.doxygen.nl
[markups]: http://www.doxygen.nl/manual/commands.html
[OpenSCAD]: http://www.openscad.org
[library location]: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Libraries
[git]: http://git-scm.com
[GitHub]: http://github.com
[forking]: http://help.github.com/forking
[pull requests]: https://help.github.com/articles/about-pull-requests
*******************************************************************************/
//----------------------------------------------------------------------------//
// conventions.
//----------------------------------------------------------------------------//
/***************************************************************************//**
\page conventions Conventions
\li \subpage dt
*******************************************************************************/
/***************************************************************************//**
\page dt Data types
\tableofcontents
\section dt_builtin Built-in
[omdl] assumes a [value] is either a number, a boolean, a string, a
list, a range, or the undefined value. What is called a vector in
the [OpenSCAD types] documentation is refereed to as a \em list
here in order to distinguish between sequential lists of values and
[Euclidean vectors].
| type | description |
|:---------:|:----------------------------------------------------|
| [value] | any valid OpenSCAD storable datum |
| number | an arithmetic value |
| boolean | a binary logic value (true or false) |
| string | a sequential list of of character values |
| list | a sequential list of arbitrary values |
| range | an arithmetic sequence |
| undef | the undefined value |
\subsection dt_special Special numerical values
| value | description |
|:---------:|:----------------------------------------------------|
| [nan] | a numerical value which is not a number |
| [inf] | a numerical value which is infinite |
\section dt_additions Additional conventions
When a list has an expected number of elements 'n', the \em count
is appended following a '-'. When there is a range of expected
elements, the lower and upper bounds are separated by a ':' and
appended (order of bounds may be reversed). When the elements
values are of an expected type, that \em type is prepended.
Combinations are used as needed as in the following table:
| name | description |
|:-----------:|:--------------------------------------------------|
| list-n | a list of of n elements |
| list-l:u | a list of l to u elements |
| type-list | a list of elements with an expected type |
| type-list-n | a list of n elements with an expected type |
\subsection dt_distinctions Distinctions
[omdl] make the following distinctions on variable types.
| name | description |
|:-----------:|:--------------------------------------------------|
| [scalar] | a single non-iterable value |
| [iterable] | a multi-part sequence of values |
| [empty] | an iterable value with zero elements |
| [even] | an even numerical value |
| [odd] | an odd numerical value |
\subsection dt_general General
From the fixed built-in set of [data types], [omdl] adds the
following general type specifications and conventions.
| name | description |
|:-------------:|:------------------------------------------------|
| [bit] | a binary numerical value (0 or 1) |
| [integer] | a positive, negative, or zero whole number |
| [decimal] | integer numbers with a fractional part |
| [index] | a list index sequence |
| [datastruct] | a defined data structure |
| [data] | an arbitrary data structure |
\subsubsection dt_index Index sequence
The data type \b index refers to a specified sequence of list
element indexes. A list index sequence may be specified in one of
the following forms.
| value / form | description |
|:---------------:|:----------------------------------------------|
| \b true | All index positions of the list [0:size-1] |
| \b false | No index positions |
| "all" | All index positions of the list [0:size-1] |
| "none" | No index positions |
| "rands" | Random index selection of the list [0:size-1] |
| "even" | The even index of the list [0:size-1] |
| "odd" | The odd index of the list [0:size-1] |
| <integer> | The single position given by an <integer> |
| <range> | The range of positions given by a <range> |
| <integer-list> | The list of positions give in <integer-list> |
The function get_index() can be used to convert a value of this
data type into a sequence of list element indexes.
\b Example
\code{.c}
// list
l1 = [a,b,c,d,e,f]
// index sequence
get_index(l1) = [0,1,2,3,4,5]
get_index(l1, "rands") = [0,2,5]
\endcode
\subsection dt_geometric Geometric
For [geometric] specifications and [geometric algebra], [omdl] adds
the following type specifications and conventions.
| name | description |
|:-----------:|:--------------------------------------------------|
| [point] | a list of numbers to identify a location in space |
| [vector] | a direction and magnitude in space |
| [line] | a start and end point in space ([line wiki]) |
| [normal] | a vector that is perpendicular to a given object |
| [pnorm] | a vector that is perpendicular to a plane |
| [plane] | a flat 2d infinite surface ([plane wiki]) |
| [coords] | a list of points in space |
| [matrix] | a rectangular array of values |
When a particular dimension is expected, the dimensional
expectation is appended to the end of the name after a '-' dash as
in the following table.
| name | description |
|:-----------:|:--------------------------------------------------|
| point-Nd | a point in an 'N' dimensional space |
| vector-Nd | a vector in an 'N' dimensional space |
| line-Nd | a line in an 'N' dimensional space |
| coords-Nd | a coordinate list in an 'N' dimensional space |
| matrix-MxN | a 'M' by 'N' matrix of values |
\subsubsection dt_line Lines and vectors
A \b vector has a direction and magnitude in space. A \b line, too,
has direction and magnitude, but also has location, as it starts at
one point in space and ends at another. Although a line can be
specified in one dimension, most library functions operate on two
and/or three dimensional lines. Operators in [omdl] make use of a
common convention for specifying Euclidean vectors and straight
lines as summarized in the following table:
Given two points \c 'p1' and \c 'p2', in space:
| no. | form | description |
|:---:|:---------:|:----------------------------------|
| 1 | p2 | a vector from the origin to 'p2' |
| 2 | [p2] | a vector from the origin to 'p2' |
| 3 | [p1, p2] | a line from 'p1' to 'p2' |
The functions is_point(), is_vector(), is_line(), line_dim(),
line_tp(), line_ip(), vector_to_line(), and line_to_vector(), are
available for type identification and convertion.
\b Example
\code{.c}
// points
p1 = [a,b,c]
p2 = [d,e,f]
// vectors
v1 = p2 = [d,e,f]
v2 = [p2] = [[d,e,f]]
// lines
v3 = [p1, p2] = [[a,b,c], [d,e,f]]
v1 == v2
v1 == v2 == v3, iff p1 == origin3d
\endcode
\subsubsection dt_plane Planes
Operators in [omdl] use a common convention for specifying planes.
A \b plane is identified by a [point] on its surface together with
its [normal] vector specified by [pnorm], which is discussed in the
following section. A list with a point and normal together specify
the plane as follows:
| name | form |
|:-------:|:-------------------:|
| [plane] | [[point], [pnorm]] |
\subsubsection dt_pnorm Planes' normal
The data type \b pnorm refers to a convention for specifying a
direction vector that is perpendicular to a plane. Given three
points \c 'p1', \c 'p2', \c 'p3', and three vectors \c 'v1',
\c 'v2', \c 'vn', the planes' [normal] can be specified in any of
the following forms:
| no. | form | description |
|:---:|:-------------:|:----------------------------------------------|
| 1 | vn | the predetermined normal vector to the plane |
| 2 | [vn] | the predetermined normal vector to the plane |
| 3 | [v1, v2] | two distinct but intersecting vectors |
| 4 | [p1, p2, p3] | three (or more) non-collinear coplanar points |
The functions is_plane() and plane_to_normal() are available for
type identification and convertion.
\b Example
\code{.c}
// points
p1 = [a,b,c];
p2 = [d,e,f];
p3 = [g,h,i];
// lines and vectors
v1 = [p1, p2] = [[a,b,c], [d,e,f]]
v2 = [p1, p3] = [[a,b,c], [g,h,i]]
vn = cross_ll(v1, v2)
// planes' normal
n1 = vn = cross_ll(v1, v2)
n2 = [vn] = cross_ll(v1, v2)
n3 = [v1, v2] = [[[a,b,c],[d,e,f]], [[a,b,c],[g,h,i]]]
n4 = [p1, p2, p3] = [[a,b,c], [d,e,f], [g,h,i]]
n1 || n2 || n3 || n4
// planes
pn1 = [p1, n1]
pn2 = [p2, n2]
pn3 = [p3, n3]
pn4 = [n4[0], n4]
pn5 = [mean(n4), n4]
pn1 == pn4
\endcode
[omdl]: https://royasutton.github.io/omdl
[Data types]: https://en.wikipedia.org/wiki/Data_type
[value]: https://en.wikipedia.org/wiki/Value_(computer_science)
[Euclidean vectors]: https://en.wikipedia.org/wiki/Euclidean_vector
[OpenSCAD types]: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#Values_and_Data_Types
[nan]: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#Infinities_and_NaNs
[inf]: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#Infinities_and_NaNs
[scalar]: https://en.wikipedia.org/wiki/Variable_(computer_science)
[iterable]: https://en.wikipedia.org/wiki/Iterator
[empty]: https://en.wikipedia.org/wiki/Empty_set
[even]: https://en.wikipedia.org/wiki/Parity_(mathematics)
[odd]: https://en.wikipedia.org/wiki/Parity_(mathematics)
[bit]: https://en.wikipedia.org/wiki/Bit
[integer]: https://en.wikipedia.org/wiki/Integer
[decimal]: https://en.wikipedia.org/wiki/Decimal
[index]: \ref dt_index
[datastruct]: https://en.wikipedia.org/wiki/Data_structure
[data]: https://en.wikipedia.org/wiki/Data
[geometric]: https://en.wikipedia.org/wiki/Geometry
[geometric algebra]: https://en.wikipedia.org/wiki/Geometric_algebra
[point]: https://en.wikipedia.org/wiki/Point_(geometry)
[vector]: https://en.wikipedia.org/wiki/Euclidean_vector
[line wiki]: https://en.wikipedia.org/wiki/Line_(geometry)
[line]: \ref dt_line
[normal]: https://en.wikipedia.org/wiki/Normal_(geometry)
[pnorm]: \ref dt_pnorm
[plane wiki]: https://en.wikipedia.org/wiki/Plane_(geometry)
[plane]: \ref dt_plane
[coords]: https://en.wikipedia.org/wiki/Coordinate_system
[matrix]: https://en.wikipedia.org/wiki/Matrix_(mathematics)
*******************************************************************************/
//----------------------------------------------------------------------------//
// openscad-amu auxiliary scripts
//----------------------------------------------------------------------------//
/*
BEGIN_SCOPE logo;
BEGIN_OPENSCAD;
include <omdl-base.scad>;
$fn = 36;
frame = triangle_ppp2sss( [ [30,0], [0,40], [30,40] ] );
core = 2 * frame / 3;
vrnd = [1, 2, 4];
cone( h=20, r=10, vr=2 );
rotate([0, 0, 360/20])
radial_repeat( n=5, angle=true )
etriangle_ls_c( vs=frame, vc=core, vr=vrnd, h=10 );
END_OPENSCAD;
BEGIN_MFSCRIPT;
include --path "${INCLUDE_PATH}" {config_base,config_png}.mfs;
views name "views" distance "250" views "top";
images name "slogo" aspect "1:1" xsizes "55";
variables set_opts_combine "views slogo";
include --path "${INCLUDE_PATH}" script_std.mfs;
END_MFSCRIPT;
END_SCOPE;
BEGIN_SCOPE quickstart;
BEGIN_OPENSCAD;
include <omdl-base.scad>;
$fn = 36;
frame = triangle_ppp2sss( [ [30,0], [0,40], [30,40] ] );
core = 2 * frame / 3;
vrnd = [1, 2, 4];
cone( h=20, r=10, vr=2 );
rotate([0, 0, 360/20])
radial_repeat( n=5, angle=true )
etriangle_ls_c( vs=frame, vc=core, vr=vrnd, h=10 );
translate([0, -50, 0])
linear_extrude(height=10)
text( text="omdl", size=20, halign="center", valign="center" );
END_OPENSCAD;
BEGIN_MFSCRIPT;
include --path "${INCLUDE_PATH}" {config_base,config_png}.mfs;
views name "views" views "top bottom right diag";
variables add_opts_combine "views";
variables add_opts "--viewall --autocenter --view=axes";
include --path "${INCLUDE_PATH}" script_new.mfs;
include --path "${INCLUDE_PATH}" config_stl.mfs;
include --path "${INCLUDE_PATH}" script_app.mfs;
END_MFSCRIPT;
END_SCOPE;
*/
//----------------------------------------------------------------------------//
// end of file
//----------------------------------------------------------------------------//