![]() |
omdl
v1.0
OpenSCAD Mechanical Design Library
|
Shape alignment tools. More...
Collaboration diagram for Alignment:Files | |
| file | align.scad |
| Shape alignment tools. | |
Functions and/or Modules | |
| module | orient_ll (l=z_axis3d_ul, r=z_axis3d_ul, ar=0) |
| Orient a line or vector to a reference line or vector. More... | |
| module | align_ll (l=z_axis3d_ul, r=z_axis3d_ul, lp=0, rp=0, ar=0, to=origin3d, ro=origin3d, lpo, rpo) |
| Align a line or vector to a reference line or vector. More... | |
| module | align_al (a=z_axis_ci, r=z_axis3d_ul, rp=0, ar=0, to=origin3d, ro=origin3d, rpo) |
| Align an objects Cartesian axis to reference line or vector. More... | |
Shape alignment tools.
| Requires: |
|---|
| include <omdl-base.scad>; |
l in all modules. The reference line is the target to align toward and is named r in all modules.lp and rp are integers that identify the point on the respective line at which the translation is anchored.lpo and rpo are only used when lp or rp is 4.| module orient_ll | ( | l | = z_axis3d_ul, |
| r | = z_axis3d_ul, |
||
| ar | = 0 |
||
| ) |
Orient a line or vector to a reference line or vector.
| l | <line-3d | line-2d> The line or vector to align. |
| r | <line-3d | line-2d> The reference line or vector. |
| ar | <decimal> Axial roll about r (in degrees). |
Rotates children so that the direction of l is aligned with the direction of r, then applies an optional axial roll ar about r. The rotation pivot is always the world origin; no translation is performed. Use align_ll() when translation to a specific point along r is also required.
When l and r are parallel or anti-parallel their cross product is the zero vector, which would leave rotate() undefined. In that case a perpendicular fallback axis is derived automatically: cross(ll,x_axis3d_uv) is tried first, then cross(ll,y_axis3d_uv) if l happens to be collinear with the x-axis. The threshold for treating the cross product as near-zero is the library constant grid_fine.
See line conventions for more information.
Definition at line 208 of file align.scad.
Here is the call graph for this function:
Here is the caller graph for this function:| module align_ll | ( | l | = z_axis3d_ul, |
| r | = z_axis3d_ul, |
||
| lp | = 0, |
||
| rp | = 0, |
||
| ar | = 0, |
||
| to | = origin3d, |
||
| ro | = origin3d, |
||
| lpo | , | ||
| rpo | |||
| ) |
Align a line or vector to a reference line or vector.
| l | <line-3d | line-2d> The line or vector to align. |
| r | <line-3d | line-2d> The reference line or vector. |
| lp | <integer> The line alignment point (see table). |
| rp | <integer> The reference-line alignment point (see table). |
| ar | <decimal> Axial roll about r (in degrees). |
| to | <vector-3d | vector-2d> Translation offset about r. |
| ro | <decimal-list-1:3 | decimal> Rotation offset about r (in degrees). |
| lpo | <point-3d | point-2d> User-supplied alignment point on l. Used when lp is 4. |
| rpo | <point-3d | point-2d> User-supplied alignment point on r. Used when rp is 4. |
The specified alignment point for the line l will be translated to the specified alignment point for the reference line r.
The transform is applied in four layers, from outermost to innermost. First, the world origin is translated to the selected alignment point on r. Second, the child is oriented so that the direction of l matches the direction of r, and the axial roll ar is applied about r. Third, the offset translation to and offset rotation ro are applied in the frame of r after orientation, meaning to shifts along and perpendicular to the reference direction rather than in world coordinates. Fourth, the selected alignment point on l is translated back to the origin to anchor the child at the correct position.
| lp, rp | alignment point |
|---|---|
| 0 | none (no translation) |
| 1 | initial |
| 2 | median |
| 3 | termination |
| 4 | user-supplied (lpo / rpo) |
See line conventions for more information.
Definition at line 281 of file align.scad.
Here is the call graph for this function:
Here is the caller graph for this function:| module align_al | ( | a | = z_axis_ci, |
| r | = z_axis3d_ul, |
||
| rp | = 0, |
||
| ar | = 0, |
||
| to | = origin3d, |
||
| ro | = origin3d, |
||
| rpo | |||
| ) |
Align an objects Cartesian axis to reference line or vector.
| a | <integer> The Cartesian axis index to align (x_axis_ci, y_axis_ci, or z_axis_ci). |
| r | <line-3d | line-2d> The reference line or vector. |
| rp | <integer> The reference-line alignment point (see table). |
| ar | <decimal> Axial roll about r (in degrees). |
| to | <vector-3d | vector-2d> Translation offset about r. |
| ro | <decimal-list-1:3 | decimal> Rotation offset about r (in degrees). |
| rpo | <point-3d | point-2d> User-supplied alignment point on r. Used when rp is 4. |
The origin will be translated to the specified alignment point for the reference line r. Equivalent to calling align_ll() with l fixed to the Cartesian axis selected by a.
Because the subject line is always the selected Cartesian axis rooted at the world origin, the alignment point on the subject line is always the origin and cannot be overridden. The parameters lp and lpo of align_ll() are therefore fixed to 0 and origin3d respectively and are not exposed here.
| rp | alignment point |
|---|---|
| 0 | none (no translation) |
| 1 | initial |
| 2 | median |
| 3 | termination |
| 4 | user-supplied (rpo) |
See line conventions for more information.
Definition at line 366 of file align.scad.
Here is the call graph for this function: