ianmackenzie / elm-geometry

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

Add Axis3d.intersectionWithSketchPlane #124

Open MartinSStewart opened 4 years ago

MartinSStewart commented 4 years ago

I've found it helpful to have the following function.

{-| Try to find the unique intersection point of an axis with a sketch plane. If the axis does not intersect the sketch plane, or if it is coplanar with it (lying perfectly in the sketch plane), returns Nothing.
-}
intersectionWithSketchPlane : SketchPlane3d units coordinates { defines : coordinates2d } -> Axis3d units coordinates -> Maybe (Point2d units coordinates2d)
intersectionWithSketchPlane sketchPlane axis3d =
    Axis3d.intersectionWithPlane (SketchPlane3d.toPlane sketchPlane) axis3d |> Maybe.map (Point3d.projectInto sketchPlane)

It behaves the same way as Axis3d.intersectionWithPlane except that it returns a 2d point on the sketch plane rather than a 3d point in global coordinates.

ianmackenzie commented 4 years ago

I like it, makes sense! Will throw that in when I get a chance...