A Circle2d is defined by its center point and radius. This module includes
functionality for
Construct a circle from its radius and center point:
exampleCircle =
Circle2d.atPoint (Point2d.meters 1 2)
(Length.meters 3)If you pass a negative radius, the absolute value will be used.
Construct a circle from its radius and center point. Flipped version of
atPoint that may be more useful in some situations like constructing a bunch
of circles of the same radius at different points:
circles =
List.map (Circle2d.withRadius radius) listOfPointsConstruct a circle at the origin with the given radius.
Attempt to construct a circle that passes through the three given points:
Circle2d.throughPoints
Point2d.origin
(Point2d.meters 1 0)
(Point2d.meters 0 1)
--> Just <|
--> Circle2d.atPoint (Point2d.meters 0.5 0.5)
--> (Length.meters 0.7071)If the three given points are collinear, returns Nothing:
Circle2d.throughPoints
Point2d.origin
(Point2d.meters 2 0)
(Point2d.meters 4 0)
--> NothingConstruct a circle by rotating a point on the circle around a given center point. The center point is given first and the point on the circle is given second.
Circle2d.sweptAround Point2d.origin
(Point2d.meters 2 0)
--> Circle2d.atOrigin (Length.meters 2)The above example could be rewritten as
Point2d.meters 2 0
|> Circle2d.sweptAround Point2d.originand if you wanted to create many concentric circles all centered on a specific point but passing through several other different points, you could use something like
concentricCircles =
List.map (Circle2d.sweptAround centerPoint) pointsGet the center point of a circle.
Get the radius of a circle.
Get the diameter of a circle (twice the radius).
Get the area of a circle.
Get the circumference (perimeter) of a circle.
Get the minimal bounding box containing a given circle.
Circle2d.boundingBox exampleCircle
--> BoundingBox2d.from
--> (Point2d.meters -2 -1)
--> (Point2d.meters 4 5)Convert a circle to a 360 degree arc.
Check if a circle contains a given point.
Check if a circle intersects with a given bounding box. This function will return true if the circle intersects the edges of the bounding box or is fully contained within the bounding box.
boundingBox =
BoundingBox2d.from
(Point2d.meters 2 0)
(Point2d.meters 3 2)
circle =
Circle2d.atOrigin (Length.meters 3)
Circle2d.intersectsBoundingBox boundingBox circle
--> TrueThese transformations generally behave just like the ones in the Point2d
module.
Scale a circle about a given point by a given scale.
Rotate a circle around a given point by a given angle.
Translate a circle by a given displacement.
Translate a circle in a given direction by a given distance.
Mirror a circle across a given axis.
Convert a circle from one units type to another, by providing a conversion factor given as a rate of change of destination units with respect to source units.
Convert a circle from one units type to another, by providing an 'inverse' conversion factor given as a rate of change of source units with respect to destination units.
Take a circle defined in global coordinates, and return it expressed in local coordinates relative to a given reference frame.
Take a circle considered to be defined in local coordinates relative to a given reference frame, and return that circle expressed in global coordinates.