Download or view Tire.frink in plain text format
/** This is a class that parses information about a tire maybe using American
tire specifications. */
class Tire
{
var width
var aspect
var wheelDiameter
var construction
var sidewallHeight
var tireDiameter
/** Construct a new tire specification from a string like "265/50 R 20" */
new[str] :=
{
if [usage, width, aspect, construction, wheelDiameter] = str =~ %r/^([A-Z]+)\s*(\d+)\s*\/\s*(\d+)\s*([A-Z]+?)\s*(\d+)/i
{
println["matched $str"]
width = eval[width] mm
println["width is parsed as $width"]
aspect = eval[aspect]
wheelDiameter = eval[wheelDiameter] in
println["wheel diameter is $wheelDiameter"]
println["Construction is $construction"]
sidewallHeight = aspect/100 width
tireDiameter = wheelDiameter + 2 sidewallHeight
} else
{
println["unmatched line $str"]
}
}
/** See https://mathworld.wolfram.com/EllipticTorus.html */
toroidVolume[] :=
{
a = sidewallHeight/2
b = width/2
c = (wheelDiameter / 2) + (sidewallHeight / 2)
return 2 pi^2 a b c
}
}
Download or view Tire.frink in plain text format
This is a program written in the programming language Frink.
For more information, view the Frink
Documentation or see More Sample Frink Programs.
Alan Eliasen was born 20217 days, 23 hours, 23 minutes ago.