omdl
v0.6.1
OpenSCAD Mechanical Design Library
|
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 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 |
value | description |
---|---|
nan | a numerical value which is not a number |
inf | a numerical value which is infinite |
When a list has an expected number of elements 'n', the 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 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 |
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 |
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 |
The data type 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 |
---|---|
true | All index positions of the list [0:size-1] |
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.
Example
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 |
The data type line refers to a convention for specifying a line or a vector. A vector is a direction and magnitude in space. A line, too, has direction and magnitude, but also has location, as it starts at one point in space and ends at another. 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 'p1'
and 'p2'
, in space:
no. | form | description |
---|---|---|
1 | p2 | a line or vector from the origin to 'p2' |
2 | [p2] | a line or vector from the origin to 'p2' |
3 | [p1, p2] | line or vector from 'p1' to 'p2' |
The functions get_line_dim(), get_line_tp(), get_line_ip(), and get_line2origin(), are available to identify the dimension of and convert a line into a vector or point.
Example
Operators in omdl use a common convention for specifying planes. A 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] |
The data type pnorm refers to a convention for specifying a direction vector that is perpendicular to a plane. Given three points 'p1'
, 'p2'
, 'p3'
, and three vectors 'v1'
, 'v2'
, '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 function get_pnorm2nv() can be used to convert a value of this data type into a normal vector.
Example