ianmackenzie / elm-geometry

2D/3D geometry package for Elm
Mozilla Public License 2.0
183 stars 26 forks source link

Add Axis2d.throughPoints and Axis3d.throughPoints #116

Closed MartinSStewart closed 4 years ago

MartinSStewart commented 4 years ago

I found myself needing to create an Axis2d from a pair of points in order to mirror a triangle across that axis. It was quick to implement myself, just

throughPoints : Point2d units coordinates -> Point2d units coordinates -> Maybe (Axis2d units coordinates)
throughPoints p0 p1 =
    Direction2d.from p0 p1 |> Maybe.map (Axis2d.through p0)

but such a function seems useful enough to include even if it's simple.

ianmackenzie commented 4 years ago

Makes sense - done! Axis#d.through/Axis#d.throughPoints is also very consistent with Plane3d.through/Plane3d.throughPoints.