omdl
v0.9.5
OpenSCAD Mechanical Design Library
docs_topics.scad
Go to the documentation of this file.
1
//! Library documentation topics page.
2
/***************************************************************************/
/**
3
\file
4
\author Roy Allen Sutton
5
\date 2018-2023
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_include (include/amu/pgid_pparent_path_n.amu)
31
*******************************************************************************/
32
33
//----------------------------------------------------------------------------//
34
// Building and installing
35
//----------------------------------------------------------------------------//
36
37
/***************************************************************************/
/**
38
\page lb Building and installing
39
40
A script is available to build the library documentation. If the
41
setup script does not detect that [openscad-amu], the development
42
environment used by [omdl], is installed, it will download and set
43
it up in local cache director in the current path.
44
45
Download the omdl setup script:
46
\code{bash}
47
$ mkdir tmp && cd tmp
48
$ wget https://git.io/setup-omdl.bash
49
$ chmod +x setup-omdl.bash
50
\endcode
51
52
Fetch and install the latest library distribution:
53
\code{bash}
54
./setup-omdl.bash --branch-list tags1 --yes --install
55
\endcode
56
57
A specific version, say v2.9, can be installed using:
58
\code{bash}
59
./setup-omdl.bash --branch v2.9 --yes --install
60
\endcode
61
62
View documentation:
63
\code{bash}
64
$ google-chrome .local/share/OpenSCAD/docs/html/index.html
65
\endcode
66
67
The \c html documentation will be installed to the OpenSCAD user
68
library path in a sub-folder \c 'docs/html'. The above example
69
assumes a Linux OS.
70
71
[omdl]: https://royasutton.github.io/omdl
72
[repository]: https://github.com/royasutton/omdl
73
[openscad-amu]: https://royasutton.github.io/openscad-amu
74
[GNU Make]: https://www.gnu.org/software/make
75
*******************************************************************************/
76
77
//----------------------------------------------------------------------------//
78
// How to use library modules
79
//----------------------------------------------------------------------------//
80
81
/***************************************************************************/
/**
82
\page lu How to use library modules
83
84
The \em standard library includes are wrapped into a base include
85
file. There has been an attempt to include only the smallest set
86
required or commonly used library features. All other modules must
87
be manually included as needed prior to use.
88
89
\amu_shell omdl_base ( "grep include omdl-base.scad | awk -v FS='(<|>)' '{print $2}'" ++rmnl )
90
\amu_word omdl_base_cnt ( words="${omdl_base}" t=" " r="^" ++count)
91
\amu_word omdl_base ( words="${omdl_base}" t=" " r="^" ++list)
92
\amu_table
93
(
94
id="omdl_base" table_caption="standard base includes (omdl-base.scad)"
95
columns="3" cell_texts="${omdl_base}"
96
)
97
98
To include the base library modules, use the wrapper as follows:
99
100
\code{.C}
101
include <omdl-base.scad>;
102
103
...
104
\endcode
105
106
This will read the \b \amu_eval(${omdl_base_cnt}) files listed in
107
table above. Library modules not listed, must be explicitly
108
included prior to use. The include requirements are outlined at the
109
start of the detailed description for each module. See the example
110
script in \ref tools_drafting for more information.
111
*******************************************************************************/
112
113
//----------------------------------------------------------------------------//
114
// Development conventions
115
//----------------------------------------------------------------------------//
116
117
/***************************************************************************/
/**
118
\page conventions Development conventions
119
120
/+
121
add to main conventions page until the section contents grows
122
123
\li \subpage dt
124
125
\page dt Data types and values
126
\tableofcontents
127
+/
128
129
\li \subpage dt_base
130
\li \subpage dt_index
131
\li \subpage dt_euclidean
132
*******************************************************************************/
133
134
//
135
// Data types and values
136
//
137
138
// Base types and values
139
/***************************************************************************/
/**
140
\page dt_base Base types and values
141
142
OpenSCAD specified a \em value to be either a number, a boolean, a
143
string, a range, a vector or or the undefined value. See [OpenSCAD
144
types]. What is called a vector in the [OpenSCAD types]
145
documentation is refereed to as a \em list here in order to
146
distinguish between sequential lists of general or compound-values
147
and [Euclidean vectors] of numbers.
148
149
| type | description |
150
|:---------:|:----------------------------------------------------|
151
| boolean | a binary logic value (\b true or \b false) |
152
| number | a numerical value |
153
| string | an iterable sequence of of character values |
154
| list | an iterable sequential of arbitrary values |
155
| range | an arithmetic sequence |
156
| function | a function literal or variable containing functions |
157
158
\subsubsection dt_special Special values
159
160
| value | description |
161
|:---------:|:----------------------------------------------------|
162
| undef | a value with no definition |
163
| "" | a string with no characters, the empty string |
164
| [] | a list with no element-values, the empty list |
165
| [nan] | a numerical value which is not a number |
166
| [inf] | a numerical value which is infinite |
167
168
\subsubsection dt_convention Specification conventions
169
170
For convenience, the flowing naming conventions are used to
171
reference common [data types] used within the library.
172
173
| name | description |
174
|:-------------:|:--------------------------------------------------|
175
| [value] | any dataum that can be stored in OpenSCAD |
176
| [scalar] | a single non-iterable value |
177
| [iterable] | any value with iterable elements |
178
| [empty] | any iterable value with zero elements |
179
| [bit] | a binary numerical value (0 or 1) |
180
| [integer] | a positive, negative, or zero whole number |
181
| [even] | an even integer |
182
| [odd] | an odd integer |
183
| [decimal] | integer numbers with a fractional part |
184
| [index] | a list index sequence |
185
| [datastruct] | a defined data structure |
186
| [data] | an arbitrary data structure |
187
| [map] | data store of keys mapped to values |
188
| [table] | data store of values arranged in rows and columns |
189
190
When a list has an expected number of elements '-n', the expected
191
number is appended. When there is a range of expected elements, the
192
lower and upper bounds are separated by a ':' and appended. When
193
the list elements values are of a specified data type, that \em
194
type is added before the name. See the following tables for a few
195
examples.
196
197
| name | description |
198
|:-------------:|:--------------------------------------------------|
199
| list-n | a list of of n elements values |
200
| list-l:u | a list of l to u elements values |
201
| type-list | a list of elements with an expected type |
202
| type-list-n | a list of n elements with an expected type |
203
204
[OpenSCAD types]: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#Values_and_data_types
205
[nan]: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#Infinities_and_NaNs
206
[inf]: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#Infinities_and_NaNs
207
208
[data types]: https://en.wikipedia.org/wiki/Data_type
209
210
[value]: https://en.wikipedia.org/wiki/Value_(computer_science)
211
[scalar]: https://en.wikipedia.org/wiki/Variable_(computer_science)
212
[iterable]: https://en.wikipedia.org/wiki/Iterator
213
[empty]: https://en.wikipedia.org/wiki/Empty_set
214
215
[bit]: https://en.wikipedia.org/wiki/Bit
216
217
[integer]: https://en.wikipedia.org/wiki/Integer
218
[even]: https://en.wikipedia.org/wiki/Parity_(mathematics)
219
[odd]: https://en.wikipedia.org/wiki/Parity_(mathematics)
220
221
[decimal]: https://en.wikipedia.org/wiki/Decimal
222
[index]: \ref dt_index
223
[datastruct]: https://en.wikipedia.org/wiki/Data_structure
224
[data]: https://en.wikipedia.org/wiki/Data
225
226
[map]: https://en.wikipedia.org/wiki/Associative_array
227
[table]: https://en.wikipedia.org/wiki/Table_(information)
228
229
*******************************************************************************/
230
231
// Index sequence generation
232
/***************************************************************************/
/**
233
\page dt_index Index sequence generation
234
235
The data type \b index refers to a specified sequence of list
236
element indexes. A list index sequence may be specified in one of
237
the following forms.
238
239
| value / form | description |
240
|:---------------:|:----------------------------------------------|
241
| \b true | All index positions of the list [0:size-1] |
242
| \b false | No index positions |
243
| "all" | All index positions of the list [0:size-1] |
244
| "none" | No index positions |
245
| "rands" | Random index selection of the list [0:size-1] |
246
| "even" | The even index of the list [0:size-1] |
247
| "odd" | The odd index of the list [0:size-1] |
248
| <integer> | The single position given by an <integer> |
249
| <range> | The range of positions given by a <range> |
250
| <integer-list> | The list of positions give in <integer-list> |
251
252
The function index_gen() can be used to convert a value of this
253
data type into a sequence of list element indexes.
254
255
\b Example
256
257
\code{.c}
258
// list
259
l1 = [a,b,c,d,e,f]
260
261
// index sequence
262
index_gen(l1) = [0,1,2,3,4,5]
263
index_gen(l1, "rands") = [0,2,5]
264
\endcode
265
*******************************************************************************/
266
267
// Euclidean space data types
268
/***************************************************************************/
/**
269
\page dt_euclidean Euclidean space data types
270
271
For [geometric] specifications and [geometric algebra], omdl adopts
272
the following type specifications and conventions.
273
274
| name | description |
275
|:-----------:|:--------------------------------------------------|
276
| [point] | a list of numbers to identify a location in space |
277
| [vector] | a direction and magnitude in space |
278
| [line] | a start and end point in space ([line wiki]) |
279
| [normal] | a vector that is perpendicular to a given object |
280
| [pnorm] | a vector that is perpendicular to a plane |
281
| [plane] | a flat 2d infinite surface ([plane wiki]) |
282
| [coords] | a list of points in space |
283
| [matrix] | a rectangular array of values |
284
285
When a particular dimension is expected, the dimensional
286
expectation is appended to the end of the name after a '-' dash as
287
in the following table.
288
289
| name | description |
290
|:-----------:|:--------------------------------------------------|
291
| point-Nd | a point in an 'N' dimensional space |
292
| vector-Nd | a vector in an 'N' dimensional space |
293
| line-Nd | a line in an 'N' dimensional space |
294
| coords-Nd | a coordinate list in an 'N' dimensional space |
295
| matrix-MxN | a 'M' by 'N' matrix of values |
296
297
\subsubsection dt_line Lines and vectors
298
299
A \b vector has a direction and magnitude in space. A \b line, too,
300
has direction and magnitude, but also has location, as it starts at
301
one point in space and ends at another. Although a line can be
302
specified in one dimension, most library functions operate on two
303
and/or three dimensional lines. Operators in omdl make use of a
304
common convention for specifying Euclidean vectors and straight
305
lines as summarized in the following table:
306
307
Given two points \c 'p1' and \c 'p2', in space:
308
309
| no. | form | description |
310
|:---:|:---------:|:----------------------------------|
311
| 1 | p2 | a vector from the origin to 'p2' |
312
| 2 | [p2] | a vector from the origin to 'p2' |
313
| 3 | [p1, p2] | a line from 'p1' to 'p2' |
314
315
The functions is_point(), is_vector(), is_line(), line_dim(),
316
line_tp(), line_ip(), vol_to_point(), and vol_to_origin(), are
317
available for type identification and convertion.
318
319
\b Example
320
321
\code{.c}
322
// points
323
p1 = [a,b,c]
324
p2 = [d,e,f]
325
326
// vectors
327
v1 = p2 = [d,e,f]
328
v2 = [p2] = [[d,e,f]]
329
330
// lines
331
v3 = [p1, p2] = [[a,b,c], [d,e,f]]
332
333
v1 == v2
334
v1 == v2 == v3, iff p1 == origin3d
335
\endcode
336
337
\subsubsection dt_plane Planes
338
339
Operators in omdl use a common convention for specifying planes.
340
A \b plane is identified by a [point] on its surface together with
341
its [normal] vector specified by [pnorm], which is discussed in the
342
following section. A list with a point and normal together specify
343
the plane as follows:
344
345
| name | form |
346
|:-------:|:-------------------:|
347
| [plane] | [[point], [pnorm]] |
348
349
\subsubsection dt_pnorm Planes' normal
350
351
The data type \b pnorm refers to a convention for specifying a
352
direction vector that is perpendicular to a plane. Given three
353
points \c 'p1', \c 'p2', \c 'p3', and three vectors \c 'v1',
354
\c 'v2', \c 'vn', the planes' [normal] can be specified in any of
355
the following forms:
356
357
| no. | form | description |
358
|:---:|:-------------:|:----------------------------------------------|
359
| 1 | vn | the predetermined normal vector to the plane |
360
| 2 | [vn] | the predetermined normal vector to the plane |
361
| 3 | [v1, v2] | two distinct but intersecting vectors |
362
| 4 | [p1, p2, p3] | three (or more) non-collinear coplanar points |
363
364
The functions is_plane() and plane_to_normal() are available for
365
type identification and convertion.
366
367
\b Example
368
369
\code{.c}
370
// points
371
p1 = [a,b,c];
372
p2 = [d,e,f];
373
p3 = [g,h,i];
374
375
// lines and vectors
376
v1 = [p1, p2] = [[a,b,c], [d,e,f]]
377
v2 = [p1, p3] = [[a,b,c], [g,h,i]]
378
vn = cross_ll(v1, v2)
379
380
// planes' normal
381
n1 = vn = cross_ll(v1, v2)
382
n2 = [vn] = cross_ll(v1, v2)
383
n3 = [v1, v2] = [[[a,b,c],[d,e,f]], [[a,b,c],[g,h,i]]]
384
n4 = [p1, p2, p3] = [[a,b,c], [d,e,f], [g,h,i]]
385
386
n1 || n2 || n3 || n4
387
388
// planes
389
pn1 = [p1, n1]
390
pn2 = [p2, n2]
391
pn3 = [p3, n3]
392
pn4 = [n4[0], n4]
393
pn5 = [mean(n4), n4]
394
395
pn1 == pn4
396
\endcode
397
398
[geometric]: https://en.wikipedia.org/wiki/Geometry
399
[geometric algebra]: https://en.wikipedia.org/wiki/Geometric_algebra
400
401
[point]: https://en.wikipedia.org/wiki/Point_(geometry)
402
[vector]: https://en.wikipedia.org/wiki/Euclidean_vector
403
[line wiki]: https://en.wikipedia.org/wiki/Line_(geometry)
404
[line]: \ref dt_line
405
[normal]: https://en.wikipedia.org/wiki/Normal_(geometry)
406
[pnorm]: \ref dt_pnorm
407
[plane wiki]: https://en.wikipedia.org/wiki/Plane_(geometry)
408
[plane]: \ref dt_plane
409
[coords]: https://en.wikipedia.org/wiki/Coordinate_system
410
[matrix]: https://en.wikipedia.org/wiki/Matrix_(mathematics)
411
412
[Euclidean vectors]: https://en.wikipedia.org/wiki/Euclidean_vector
413
*******************************************************************************/
414
415
//----------------------------------------------------------------------------//
416
// Auto-tests and validation
417
//----------------------------------------------------------------------------//
418
419
/***************************************************************************/
/**
420
\page tv Auto-tests and validation
421
422
### Scripts and Results ###
423
424
The documentation for [omdl] is produced by [openscad-amu]. An
425
integral part of building the library documentation is verifying
426
that the basic operations work as expected. As [OpenSCAD] evolves,
427
changes in the language and/or compiler may break basic library
428
behavior. These validations are performed to identify library
429
routines that require updating to conform to any such changes.
430
431
| format | description
432
|:-----------------------:|:------------------------------------------
433
| \subpage tv_tree "Tree" | Tree of all test scripts and test results.
434
| \subpage tv_list "List" | A flat list of all test results.
435
| \subpage tv_fail "Fail" | A flat list of current test failures.
436
| \subpage tv_warn "Warn" | A flat list of current test warnings.
437
438
#### Current Test Failures and Warnings ####
439
440
[omdl]: https://royasutton.github.io/omdl
441
[openscad-amu]: https://royasutton.github.io/openscad-amu
442
[OpenSCAD]: http://www.openscad.org
443
*******************************************************************************/
444
445
// Validation Tests and Results
446
/***************************************************************************/
/**
447
/+
448
Define seperate pages for validation results. Modules can
449
attached results to the related page reference.
450
+/
451
452
\page tv_tree Validation Tests and Results
453
454
\page tv_list Validation Tests Summary
455
\amu_include (include/amu/validate_log_th.amu)
456
\amu_table(columns=${tv_tc} column_headings=${tv_th})
457
458
\page tv_fail Current Tests Failures
459
\page tv_warn Current Tests Warnings
460
*******************************************************************************/
461
462
//----------------------------------------------------------------------------//
463
// Build versions
464
//----------------------------------------------------------------------------//
465
466
/***************************************************************************/
/**
467
\page bi Build information
468
469
\amu_file bi_general (file="${DOXYGEN_OUTPUT}buildinfo/general.amu" ++read)
470
\amu_table
471
(
472
id="bi_general" table_caption="General"
473
columns="2" column_headings="name^value"
474
cell_texts="${bi_general}"
475
)
476
477
\amu_file bi_toolchain (file="${DOXYGEN_OUTPUT}buildinfo/toolchain.amu" ++read)
478
\amu_table
479
(
480
id="bi_toolchain" table_caption="Toolchain"
481
columns="3" column_headings="name^version^path"
482
cell_texts="${bi_toolchain}"
483
)
484
485
\amu_file bi_scopes (file="${DOXYGEN_OUTPUT}buildinfo/scopes.amu" ++read)
486
\amu_table
487
(
488
id="bi_scopes" table_caption="Scopes Filter"
489
columns="3" column_headings="name^count^value"
490
cell_texts="${bi_scopes}"
491
)
492
493
\amu_file bi_modules (file="${DOXYGEN_OUTPUT}buildinfo/modules.amu" ++read)
494
\amu_table
495
(
496
id="bi_modules" table_caption="Modules Filter"
497
columns="3" column_headings="name^count^value"
498
cell_texts="${bi_modules}"
499
)
500
501
*******************************************************************************/
502
503
/***************************************************************************/
/**
504
\page Copyright Copyright notice
505
506
\verbatim
507
\amu_include (gnu-lgpl-v2.1.txt)
508
\endverbatim
509
*******************************************************************************/
510
511
//----------------------------------------------------------------------------//
512
// end of file
513
//----------------------------------------------------------------------------//
docs_topics.scad
Generated on Thu Nov 14 2024 11:12:07 for omdl by
doxygen
with
openscad-amu