An ellipse is defined by a center point, X and Y radius, and X and Y axes (which will always be perpendicular to each other). Ellipses are symmetric about their X and Y axes. This module includes functionality for
Geometry.Types.Ellipse2d
with : { centerPoint : Point2d, xDirection : Direction2d, xRadius : Basics.Float, yRadius : Basics.Float } -> Ellipse2d
Construct an ellipse from its center point, X direction, and X and Y radii. If you pass a negative radius, the absolute value will be used.
exampleEllipse =
Ellipse2d.with
{ centerPoint =
Point2d.fromCoordinates ( 10, 10 )
, xDirection =
Direction2d.fromAngle (degrees 30)
, xRadius = 5
, yRadius = 3
}
centerPoint : Ellipse2d -> Point2d
Get the center point of an ellipse.
Ellipse2d.centerPoint exampleEllipse
--> Point2d.fromCoordinates ( 10, 10 )
xAxis : Ellipse2d -> Axis2d
Get the X axis of an ellipse.
Ellipse2d.xAxis exampleEllipse
--> Axis2d.through
--> (Point2d.fromCoordinates ( 10, 10 ))
--> (Direction2d.fromAngle (degrees 30))
yAxis : Ellipse2d -> Axis2d
Get the Y axis of an ellipse.
Ellipse2d.yAxis exampleEllipse
--> Axis2d.through
--> (Point2d.fromCoordinates ( 10, 10 ))
--> (Direction2d.fromAngle (degrees 120))
xDirection : Ellipse2d -> Direction2d
Get the direction of the ellipse's X axis.
Ellipse2d.xDirection exampleEllipse
--> Direction2d.fromAngle (degrees 30)
yDirection : Ellipse2d -> Direction2d
Get the direction of an ellipse's Y axis.
Ellipse2d.yDirection exampleEllipse
--> Direction2d.fromAngle (degrees 120)
axes : Ellipse2d -> Frame2d
Get the X and Y axes of an ellipse as a Frame2d
.
Ellipse2d.axes exampleEllipse
--> Frame2d.withXDirection
--> (Direction2d.fromAngle (degrees 30))
--> (Point2d.fromCoordinates ( 10, 10 ))
xRadius : Ellipse2d -> Basics.Float
Get the radius of an ellipse along its X axis. This may be either the minimum or maximum radius.
Ellipse2d.xRadius exampleEllipse
--> 5
yRadius : Ellipse2d -> Basics.Float
Get the radius of an ellipse along its Y axis. This may be either the minimum or maximum radius.
Ellipse2d.yRadius exampleEllipse
--> 3
area : Ellipse2d -> Basics.Float
Get the area of an ellipse.
Ellipse2d.area exampleEllipse
--> 47.1239
scaleAbout : Point2d -> Basics.Float -> Ellipse2d -> Ellipse2d
Scale an ellipse about a given point by a given scale.
exampleEllipse
|> Ellipse2d.scaleAbout Point2d.origin 3
--> Ellipse2d.with
--> { centerPoint =
--> Point2d.fromCoordinates ( 30, 30 )
--> , xDirection =
--> Direction2d.fromAngle (degrees 30)
--> , xRadius = 15
--> , yRadius = 9
--> }
rotateAround : Point2d -> Basics.Float -> Ellipse2d -> Ellipse2d
Rotate an ellipse around a given point by a given angle (in radians).
exampleEllipse
|> Ellipse2d.rotateAround Point2d.origin
(degrees 45)
--> Ellipse2d.with
--> { centerPoint =
--> Point2d.fromCoordinates ( 0, 14.142 )
--> , xDirection =
--> Direction2d.fromAngle (degrees 75)
--> , xRadius = 5
--> , yRadius = 3
--> }
translateBy : Vector2d -> Ellipse2d -> Ellipse2d
Translate an ellipse by a given displacement.
exampleEllipse
|> Ellipse2d.translateBy
(Vector2d.fromComponents ( 5, 10 ))
--> Ellipse2d.with
--> { centerPoint =
--> Point2d.fromCoordinates ( 15, 20 )
--> , xDirection =
--> Direction2d.fromAngle (degrees 30)
--> , xRadius = 5
--> , yRadius = 3
--> }
translateIn : Direction2d -> Basics.Float -> Ellipse2d -> Ellipse2d
Translate an ellipse in a given direction by a given distance;
Ellipse2d.translateIn direction distance
is equivalent to
Ellipse2d.translateBy
(Vector2d.withLength distance direction)
mirrorAcross : Axis2d -> Ellipse2d -> Ellipse2d
Mirror an ellipse across a given axis.
mirroredEllipse =
Ellipse2d.mirrorAcross Axis2d.x exampleEllipse
Ellipse2d.centerPoint mirroredEllipse
--> Point2d.fromCoordinates ( 10, -10 )
Ellipse2d.xDirection mirroredEllipse
--> Direction2d.fromAngle (degrees -30)
Ellipse2d.yDirection mirroredEllipse
--> Direction2d.fromAngle (degrees -120)
Note that if the axes of the original ellipse form a right-handed frame, then the axes of the mirrored ellipse will form a left-handed frame (and vice versa).
relativeTo : Frame2d -> Ellipse2d -> Ellipse2d
Take an ellipse defined in global coordinates, and return it expressed in local coordinates relative to a given reference frame.
localFrame =
Frame2d.atPoint (Point2d.fromCoordinates (15, 5))
Ellipse2d.relativeTo localFrame exampleEllipse
--> Ellipse2d.with
--> { centerPoint =
--> Point2d.fromCoordinates ( -5, 5 )
--> , xDirection =
--> Direction2d.fromAngle (degrees 30)
--> , xRadius = 5
--> , yRadius = 3
--> }
placeIn : Frame2d -> Ellipse2d -> Ellipse2d
Take an ellipse considered to be defined in local coordinates relative to a given reference frame, and return that circle expressed in global coordinates.
localFrame =
Frame2d.atPoint (Point2d.fromCoordinates (15, 5))
Ellipse2d.placeIn localFrame exampleEllipse
--> Ellipse2d.with
--> { centerPoint =
--> Point2d.fromCoordinates ( 25, 15 )
--> , xDirection =
--> Direction2d.fromAngle (degrees 30)
--> , xRadius = 5
--> , yRadius = 3
--> }