omdl  v0.9.5
OpenSCAD Mechanical Design Library
Utilities

Miscellaneous mathematical utilities. More...

+ Collaboration diagram for Utilities:

Files

file  utility.scad
 Miscellaneous mathematical utilities.
 

Functions

function get_fn (r)
 Return facets number for the given arc radius. More...
 
function histogram (v, m=0, cs, cb, cp, ca, cf, d=false)
 Generate a histogram for the elements of a list of values. More...
 

Detailed Description

Miscellaneous mathematical utilities.

Requires:
include <omdl-base.scad>;

Function Documentation

◆ get_fn()

function get_fn ( )

Return facets number for the given arc radius.

Parameters
r<decimal> The arc radius.
Returns
<integer> The number of facets.

This function approximates the get_fragments_from_r() code that is used by OpenSCAD to calculates the number of fragments in a circle or arc. The arc facets are controlled by the special variables $fa, $fs, and $fn.

+ Here is the caller graph for this function:

◆ histogram()

function histogram ( ,
= 0,
cs  ,
cb  ,
cp  ,
ca  ,
cf  ,
= false 
)

Generate a histogram for the elements of a list of values.

Parameters
v<data> A list of values.
m<integer> The output mode (a 5-bit encoded integer).
cs<string-list-4> A list of strings [s1, s2, s3, fs] (for custom field formatting).
Returns
<list | string> with the occurrence frequency of the elements of v.

The custom formatting strings are inserted in the output stream as follows:

  s1, value, s2, value-frequency, s3, fs

See strl_html() for description of the html formatting parameters cb, cp, ca, cf, and d.

Output mode selection:

bit Description 0 1
0 output mode numerical string
1-3 string mode format see table see table
4 field separator mode not at end all

String output modes:

B3 B2 B1 B0 Description
1 0 0 0 1 list of strings
3 0 0 1 1 text format 1
9 1 0 0 1 html format 1
15 1 1 1 1 custom formating