ianmackenzie / elm-geometry

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

Suggestion: A function `Point2d u c -> Vector2d u c -> LineSegment2d u c`in module `LineSegment2d` #110

Closed prange closed 5 years ago

prange commented 5 years ago

A function Point2d u c -> Vector2d u c -> LineSegment2d u cin module LineSegment2d

ianmackenzie commented 5 years ago

Any thoughts on what the function name would be? Brainstorming a bit:

LineSegment2d.fromStartPointAndDisplacement
LineSegment2d.fromDisplacement
LineSegment2d.sweep
LineSegment2d.extrusion

And just to make sure, I'm assuming the function would be the equivalent of doing

LineSegment2d.fromEndpoints
    ( startPoint
    , startPoint |> Point2d.translateBy displacement
    )

?

MartinSStewart commented 5 years ago

I agree this would be a useful function to have. I've ended up writing

LineSegment2d.fromEndpoints
    ( startPoint
    , startPoint |> Point2d.translateBy displacement
    )

a lot so it would be nice to have shorthand for it. As for the name, what about LineSegment2d.fromPointAndOffset or LineSegment2d.fromPointAndVector? Otherwise, I think LineSegment2d.fromDisplacement sounds fine too.

ianmackenzie commented 5 years ago

fromPointAndVector seems pretty good, especially given that there is a matching vector accessor. Should be able to throw this into the next release which I'm getting ready to publish =)