You are here: Start » AVL.NET » Function Reference » Geometry 2D » Geometry 2D Normalizations » AVL.NormalizeSegmentOrientation_ByPointDistance

AVL.NormalizeSegmentOrientation_ByPointDistance

Changes orientation of the given segment according to distance to the given point.

Namespace:AvlNet
Assembly:AVL.NET.dll

Syntax

C++
C#
 
public static void NormalizeSegmentOrientation_ByPointDistance
(
	AvlNet.Segment2D inSegment,
	AvlNet.Point2D inReferencePoint,
	out AvlNet.Segment2D outSegment
)

Parameters

Name Type Range Default Description
inSegmentAvlNet.Segment2D
inReferencePointAvlNet.Point2DA point relative to which distances are measured.
outSegmentAvlNet.Segment2DA 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.X99,000
inSegment.Point1.Y100,000
inSegment.Point2.X200,000
inSegment.Point2.Y201,000
  1. 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.
  2. 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.X200,000
    inSegment.Point2.Y201,000
    inSegment.Point1.X99,000
    inSegment.Point1.Y100,000

See also