You are here: Start » Function Reference » Geometry 2D » Geometry 2D Angle Metrics » AngleBetweenVectors
Header: | FIL.h |
---|---|
Namespace: | fil |
Module: | FoundationLite |
Measures the angle between two vectors.
Syntax
void fil::AngleBetweenVectors ( const fil::Vector2D& inVector1, const fil::Vector2D& inVector2, ftl::Optional<fil::RotationDirection::Type> inRotationDirection, ftl::Optional<float&> outAbsoluteAngle = ftl::NIL, ftl::Optional<float&> outDirectedAngle = ftl::NIL )
Parameters
Name | Type | Default | Description | |
---|---|---|---|---|
![]() |
inVector1 | const Vector2D& | Start vector | |
![]() |
inVector2 | const Vector2D& | Target vector | |
![]() |
inRotationDirection | Optional<RotationDirection::Type> | NIL | Clockwise, counter-clockwise or automatic (by smaller angle) |
![]() |
outAbsoluteAngle | Optional<float&> | NIL | Angle value used for measurements <0; 360> |
![]() |
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 ftl::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.