Back to Aurora Vision Library website

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

NormalizeSegmentOrientation_ByBaseOrientation


Header: AVL.h
Namespace: avl
Module: FoundationLite

Changes orientation of the given segment according to base orientation.

Syntax

C++
C#
 
void avl::NormalizeSegmentOrientation_ByBaseOrientation
(
	const avl::Segment2D& inSegment,
	const float inBaseOrientation,
	avl::Segment2D& outSegment
)

Parameters

Name Type Default Description
Input value inSegment const Segment2D&
Input value inBaseOrientation const float 0.0f An angle relative to which angle differences are calculated
Output value outSegment Segment2D& A 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