by GregBuchholz · 10y ago · 0 comments
ctx.arc(center=Point(10,20), radius=30, beginAngle=0, endAngle=6.28, Clockwise);
...and don't forget about units of measurement/dimensional analysis.https://stackoverflow.com/questions/107243/are-units-of-meas...
ctx.arc(center=Point(10cm,20cm), radius=30mm, beginAngle=0rad, endAngle=6.28rad, Clockwise);I'd like to be able to say the end angle has to be less than the start angle, that the unit has to be radians (AKA unit-less :), the unit of radius & that negative values are sensical, and so forth; and have all these properties checked by a compiler.
Which I can do in some modern languages, surprisingly. :)
data Directionality = Clockwise | Anticlockwise
data AngularInterval = {
beginAngle :: Double,
endAngle :: Double,
directionality :: Directionality
}
... and then we're down to three parameters, all of different types (so no opportunity for mistakes, assuming static checking) and who knows, you might even have other uses for AngularInterval.