A LineSegment3d
is a line between two points in 3D. This module contains
functionality such as:
Geometry.Types.LineSegment3d units coordinates
fromEndpoints : ( Point3d units coordinates, Point3d units coordinates ) -> LineSegment3d units coordinates
Construct a line segment from its two endpoints:
exampleLineSegment =
LineSegment3d.fromEndpoints
( Point3d.meters 1 2 3
, Point3d.meters 4 5 6
)
from : Point3d units coordinates -> Point3d units coordinates -> LineSegment3d units coordinates
Construct a line segment from the first point to the second;
LineSegment3d.from firstPoint secondPoint
is equivalent to
LineSegment3d.fromEndpoints ( firstPoint, secondPoint )
fromPointAndVector : Point3d units coordinates -> Vector3d units coordinates -> LineSegment3d units coordinates
Construct a line segment given its start point and the vector from its start point to its end point;
LineSegment3d.fromPointAndVector point vector
is equivalent to
LineSegment3d.fromEndpoints
( point
, point |> Point3d.translateBy vector
)
along : Axis3d units coordinates -> Quantity Basics.Float units -> Quantity Basics.Float units -> LineSegment3d units coordinates
Construct a line segment lying on the given axis, with its endpoints at the given distances from the axis' origin point.
LineSegment3d.along Axis3d.x
(Length.meters 3)
(Length.meters 5)
--> LineSegment3d.fromEndpoints
--> ( Point3d.meters 3 0 0
--> , Point3d.meters 5 0 0
--> )
on : SketchPlane3d units coordinates3d { defines : coordinates2d } -> LineSegment2d units coordinates2d -> LineSegment3d units coordinates3d
Construct a 3D line segment lying on a sketch plane by providing a 2D line segment specified in XY coordinates within the sketch plane.
LineSegment3d.on SketchPlane3d.yz <|
LineSegment2d.fromEndpoints
( Point2d.meters 1 2
, Point2d.meters 3 4
)
--> LineSegment3d.fromEndpoints
--> ( Point3d.meters 0 1 2
--> , Point3d.meters 0 3 4
--> )
startPoint : LineSegment3d units coordinates -> Point3d units coordinates
Get the start point of a line segment.
endPoint : LineSegment3d units coordinates -> Point3d units coordinates
Get the end point of a line segment.
endpoints : LineSegment3d units coordinates -> ( Point3d units coordinates, Point3d units coordinates )
Get the endpoints of a line segment as a tuple.
( p1, p2 ) =
LineSegment3d.endpoints lineSegment
midpoint : LineSegment3d units coordinates -> Point3d units coordinates
Get the midpoint of a line segment.
LineSegment3d.midpoint exampleLineSegment
--> Point3d.meters 2.5 3.5 4.5
length : LineSegment3d units coordinates -> Quantity Basics.Float units
Get the length of a line segment.
LineSegment3d.length exampleLineSegment
--> Length.meters 5.1962
direction : LineSegment3d units coordinates -> Maybe (Direction3d coordinates)
Get the direction from a line segment's start point to its end point. If the
line segment has zero length (the start and end points are the same), returns
Nothing
.
LineSegment3d.direction exampleLineSegment
--> Just <|
--> Direction3d.xyZ (Angle.degrees 45)
--> (Angle.degrees 35.26)
axis : LineSegment3d units coordinates -> Maybe (Axis3d units coordinates)
Construct an axis collinear with a given line segment; the origin point of the axis will be the
start point of the line segment and the direction of the axis will be the direction of the line
segment. Returns Nothing
if the line segment has zero length.
perpendicularDirection : LineSegment3d units coordinates -> Maybe (Direction3d coordinates)
Get an arbitrary direction perpendicular to a line segment. If the line
segment has zero length, returns Nothing
.
LineSegment3d.perpendicularDirection exampleLineSegment
--> Just (Direction3d.yz (Angle.degrees 135))
vector : LineSegment3d units coordinates -> Vector3d units coordinates
Get the vector from a line segment's start point to its end point.
LineSegment3d.vector exampleLineSegment
--> Vector3d.meters 2 2 2
boundingBox : LineSegment3d units coordinates -> BoundingBox3d units coordinates
Get the minimal bounding box containing a line segment.
LineSegment3d.boundingBox exampleLineSegment
--> BoundingBox3d.from
--> (Point3d.meters 1 2 3)
--> (Point3d.meters 4 5 6)
interpolate : LineSegment3d units coordinates -> Basics.Float -> Point3d units coordinates
Interpolate a line segment between its start and end points; a value of 0.0 corresponds to the start point of the line segment, a value of 0.5 corresponds to its midpoint and a value of 1.0 corresponds to its end point. Values less than 0.0 or greater than 1.0 can be used to extrapolate.
LineSegment3d.interpolate exampleLineSegment (1 / 3)
--> Point3d.meters 2 4 5
LineSegment3d.interpolate exampleLineSegment (-1 / 3)
--> Point3d.meters 0 1 2
If you just need to interpolate between two points, you don't have to construct
a line segment first - you can use Point3d.interpolateFrom
directly.
intersectionWithPlane : Plane3d units coordinates -> LineSegment3d units coordinates -> Maybe (Point3d units coordinates)
Try to find the unique intersection point of a line segment with a plane. If
the line segment does not intersect the plane, or if it is coplanar with it
(lying perfectly in the plane), returns Nothing
.
signedDistanceAlong : Axis3d units coordinates -> LineSegment3d units coordinates -> Quantity.Interval.Interval Basics.Float units
Measure the distance of a line segment along an axis. This is the range of distances along the axis resulting from projecting the line segment perpendicularly onto the axis.
Note that reversing the line segment will not affect the result.
signedDistanceFrom : Plane3d units coordinates -> LineSegment3d units coordinates -> Quantity.Interval.Interval Basics.Float units
Measure the distance of a line segment from a plane. If the returned interval:
Note that reversing the line segment will not affect the result.
These transformations generally behave just like the ones in the Point3d
module.
reverse : LineSegment3d units coordinates -> LineSegment3d units coordinates
Reverse a line segment, swapping its start and end points.
scaleAbout : Point3d units coordinates -> Basics.Float -> LineSegment3d units coordinates -> LineSegment3d units coordinates
Scale a line segment about the given center point by the given scale.
rotateAround : Axis3d units coordinates -> Angle -> LineSegment3d units coordinates -> LineSegment3d units coordinates
Rotate a line segment around a given axis by a given angle.
translateBy : Vector3d units coordinates -> LineSegment3d units coordinates -> LineSegment3d units coordinates
Translate a line segment by a given displacement.
translateIn : Direction3d coordinates -> Quantity Basics.Float units -> LineSegment3d units coordinates -> LineSegment3d units coordinates
Translate a line segment in a given direction by a given distance.
mirrorAcross : Plane3d units coordinates -> LineSegment3d units coordinates -> LineSegment3d units coordinates
Mirror a line segment across a plane.
projectOnto : Plane3d units coordinates -> LineSegment3d units coordinates -> LineSegment3d units coordinates
Find the orthographic projection of a line segment onto a plane.
mapEndpoints : (Point3d units1 coordinates1 -> Point3d units2 coordinates2) -> LineSegment3d units1 coordinates1 -> LineSegment3d units2 coordinates2
Transform the start and end points of a line segment by a given function
and create a new line segment from the resulting points. Most other
transformation functions can be defined in terms of mapEndpoints
; for example,
LineSegment3d.projectOnto plane
is equivalent to
LineSegment3d.mapEndpoints (Point3d.projectOnto plane)
at : Quantity Basics.Float (Quantity.Rate units2 units1) -> LineSegment3d units1 coordinates -> LineSegment3d units2 coordinates
Convert a line segment 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.
at_ : Quantity Basics.Float (Quantity.Rate units1 units2) -> LineSegment3d units1 coordinates -> LineSegment3d units2 coordinates
Convert a line segment 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.
relativeTo : Frame3d units globalCoordinates { defines : localCoordinates } -> LineSegment3d units globalCoordinates -> LineSegment3d units localCoordinates
Take a line segment defined in global coordinates, and return it expressed in local coordinates relative to a given reference frame.
placeIn : Frame3d units globalCoordinates { defines : localCoordinates } -> LineSegment3d units localCoordinates -> LineSegment3d units globalCoordinates
Take a line segment considered to be defined in local coordinates relative to a given reference frame, and return that line segment expressed in global coordinates.
projectInto : SketchPlane3d units coordinates3d { defines : coordinates2d } -> LineSegment3d units coordinates3d -> LineSegment2d units coordinates2d
Project a line segment into a given sketch plane.