Skip to content

hrbishop/small_projects

Repository files navigation

FractionalArithmetic

FractionalArithmetic was written to support woodworking when using fractional inches and not millimeters.
There is a smallest unit of fractional arithmetic that woodworkers are used to working with, in my case
it is 1/32".  If I make my default base 32, then all computations requiring a final result to be reported
as a nearest fraction will result in a dimension of 1/32" or greater.  So when I set up a machine to conduct
an operation I know the accuracy I should be dialing in.

The FractionalArithmetic module uses the "rational" implementation in Ruby core.  However, the FractionalArithmetic
extends the numeric value by taking in  a string and converting it to a MixedFraction (MF) value.
MF can be added, subtracted, multiplied and divided by another MF value or a numeric value.
Additionally, the base can be exchanged to a new base for an MF value.  An MF value
can be printed out or converted to a string where the fractional display is available to the user.

Lastly a decimal value can be converted to an MF value or an MF value convert to a float with to_f.

LWD is a class provided for Length, Width and Depth joining of rectangular shapes.  This class provides
the basis for solid modeling.  A class instance is able to form the union or intersection of two rectangular
solids based on the common dimensions.  So a rectangular solid with LWD and a second solid the length, width
and depth dimensions are taken as common to both.  Lastly, a tally method provides a summary of all dimensions
and finds commonality in face views to report the total having the same dimensions.

fractionalArithmetic_spec demonstrates the use of the module methods and expected results.

About

small projects contains some ruby code for additional specific functionality

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages