Back to Adaptive Vision Studio website

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

NormalizeSegmentOrientation_ByBaseOrientation


Changes orientation of the given segment according to base orientation.

Name Type Description
inSegment Segment2D
inBaseOrientation Real An angle relative to which angle differences are calculated
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

Complexity Level

This filter is available on Basic Complexity Level.

Filter Group

This filter is member of NormalizeSegment filter group.

See Also