Back to FabImage Library website
You are here: Start » Function Reference » Geometry 2D » Geometry 2D Normalizations » NormalizeSegmentOrientation_ByPointDistance
Header: | FIL.h |
---|---|
Namespace: | fil |
Module: | FoundationLite |
Changes orientation of the given segment according to distance to the given point.
Syntax
C++
C#
void fil::NormalizeSegmentOrientation_ByPointDistance ( const fil::Segment2D& inSegment, const fil::Point2D& inReferencePoint, fil::Segment2D& outSegment )
Parameters
Name | Type | Default | Description | |
---|---|---|---|---|
![]() |
inSegment | const Segment2D& | ||
![]() |
inReferencePoint | const Point2D& | A point relative to which distances are measured | |
![]() |
outSegment | Segment2D& | A segment in which the first point is closer to inReferencePoint |
Description
This operation changes the orientation of the inSegment segment according to the distance between the input segment's vertices and given inReferencePoint. The resulting segment has the first vertex closer to the inReferencePoint.
Examples
Let's consider two cases with the same input segment, but different inReferencePoint.
The coordinates of the segment are as follows:
inSegment.Point1.X | 99,000 |
inSegment.Point1.Y | 100,000 |
inSegment.Point2.X | 200,000 |
inSegment.Point2.Y | 201,000 |
-
Let's assume the inReferencePoint to have coordinates X = 99, Y = 0.
The distance between the first vertex of the segment (X = 99, Y = 100) is equal to 100, whereas the distance between the second vertex of the segment (X = 200, Y = 201) is about 225. That means the first vertex is closer to the inReferencePoint, so the resulting segment will have the same coordinates as the input segment. -
Now, let's assume the inReferencePoint to have coordinates X = 300, Y = 201.
The distance between the first vertex of the segment (X = 99, Y = 100) is about 225, whereas the distance between the second vertex of the segment (X = 200, Y = 201) is equal to 100. That means the second vertex is closer to inReferencePoint, so the resulting segment will have reversed vertices. Their coordinates will be as follows:inSegment.Point2.X 200,000 inSegment.Point2.Y 201,000 inSegment.Point1.X 99,000 inSegment.Point1.Y 100,000
See Also
- SegmentOrientation – Computes the orientation of a segment.
- NormalizeSegmentOrientation_ByCoordinate – Changes orientation of the given segment according to coordinates along selected axis.
- NormalizeSegmentOrientation_ByBaseOrientation – Changes orientation of the given segment according to base orientation.