Back to Aurora Vision Library website

You are here: Start » Function Reference » Geometry 2D » Geometry 2D Angle Metrics » AngleBetweenVectors

AngleBetweenVectors


Header: AVL.h
Namespace: avl
Module: FoundationLite

Measures the angle between two vectors.

Syntax

C++
C#
 
void avl::AngleBetweenVectors
(
	const avl::Vector2D& inVector1,
	const avl::Vector2D& inVector2,
	atl::Optional<avl::RotationDirection::Type> inRotationDirection,
	atl::Optional<float&> outAbsoluteAngle = atl::NIL,
	atl::Optional<float&> outDirectedAngle = atl::NIL
)

Parameters

Name Type Default Description
Input value inVector1 const Vector2D& Start vector
Input value inVector2 const Vector2D& Target vector
Input value inRotationDirection Optional<RotationDirection::Type> NIL Clockwise, counter-clockwise or automatic (by smaller angle)
Output value outAbsoluteAngle Optional<float&> NIL Angle value used for measurements <0; 360>
Output value outDirectedAngle Optional<float&> NIL Angle value used for clockwise transformations <-360; 360>

Optional Outputs

The computation of following outputs can be switched off by passing value atl::NIL to these parameters: outAbsoluteAngle, outDirectedAngle.

Read more about Optional Outputs.

Description

Note that because of inaccuracies of floating-point arithmetic, some geometric operations (including this one) may lead to unpredictable results for degenerated cases. In this filter such a case occurs when a zero vector is given on input.

Examples

AngleBetweenVectors performed on two vectors: inVector1 DeltaX = 10, DeltaY = 10, inVector2 DeltaX = -5, DeltaY = 5, inRotationDirection = CounterClockwise.
outAbsoluteAngle returns 270, and outDirectedAngle returns -270.