-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds a constructor for regular polygons #148
Conversation
Couple small comments above but I think this looks good! |
Have start point be right end of bottom edge and end point be left end of bottom edge (assuming Y-up)
Argh I thought I had left a comment about API design here but it looks like it got lost somehow - I think we talked about switching to a record argument and supporting Polygon2d.regular :
{ numSides : Int
, centerPoint : Point2d units coordinates
, circumradius : Quantity Float units
}
-> Polygon2d units coordinates
Polygon2d.fromCircumcircle :
Circle2d units coordinates
-> Int
-> Polygon2d units coordinates
Polygon2d.fromIncircle :
Circle2d units coordinates
-> Int
-> Polygon2d units coordinates |
I believe we agreed to do the first, then leave the rest for later. With regard to record vs. positional, I don't have any strong opinion. Since all the arguments have distinct types, I don't think the record particularly adds much value and so perhaps is just unnecessary verbose? But I could definitely swing either way.
(Also I wonder if the names should be |
Oops, forgot to get back to this - I think I kind of like the record argument for explicitness/clarity (you can't mess up the order, but I think when reading the code it would be nice to have that confirmation that for example the And even Polygon2d.regular
{ numSides = n
, centerPoint = p
, circumradius = r |> Quantity.divideBy (cos (pi / toFloat n))
} So I'm tempted to say let's just switch |
Looks good! OK to merge? |
Sure, go ahead. |
Adds a constructor for regular polygons that are aligned with the x axis.