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

AVL.NormalizeSegmentOrientation_ByBaseOrientation

Changes orientation of the given segment according to base orientation.

Namespace:AvlNet
Assembly:AVL.NET.dll

Syntax

C++
C#
 
public static void NormalizeSegmentOrientation_ByBaseOrientation
(
	AvlNet.Segment2D inSegment,
	float inBaseOrientation,
	out AvlNet.Segment2D outSegment
)

Parameters

Name Type Range Default Description
inSegmentAvlNet.Segment2D
inBaseOrientationfloat0.0fAn angle relative to which angle differences are calculated. Default value: 0.0f.
outSegmentAvlNet.Segment2DA segment which orientation is closer to inBaseOrientation.

Description

This operation changes the orientation of the inSegment segment according to the given angle. The resulting segment has possibly the smallest difference between its orientation and inBaseOrientation. In other words, the function returns the same segment as inSegment or rotated by 180 degrees - depending on the difference between the orientations.

Examples

Let's consider two cases with the same input segment, but different inBaseOrientation. 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 inBaseOrientation to be equal to 90 degrees.

    The orientation of the input segment is 45 degrees, whereas the orientation of the segment rotated by 180 degrees would be 225 degrees. The difference between 90 and 45 degrees is smaller than the one between 90 and 225, so the output segment would be the same as input.
  2. Now, let's assume the inBaseOrientation to be 180 degrees.

    The orientation of the input segment is still 45 degrees, and the orientation of the segment rotated by 180 degrees is also still 225 degrees. But now, the difference between 90 and 45 degrees is greater than the one between 90 and 225, so the output segment would be rotated by 180 degrees. The vertexes of the output segment would be swapped as follows:
    inSegment.Point2.X200,000
    inSegment.Point2.Y201,000
    inSegment.Point1.X99,000
    inSegment.Point1.Y100,000

See also