A Vector2, broken down as a separate magnitude and direction. Assumes that the direction given is normalized. More...
#include <separated_vector.h>
Public Member Functions | |
SeparatedVector2 () | |
SeparatedVector2 (Vector2 direction, Scalar magnitude) | |
SeparatedVector2 (Vector2 vector) | |
Vector2 | GetVector () const |
Returns the vector representation of the vector. More... | |
Vector2 | GetDirection () const |
Returns just the normalized direction vector. More... | |
Scalar | GetAlignment (const SeparatedVector2 &other) const |
Radians | AngleTo (const SeparatedVector2 &other) const |
Returns the scalar angle between the two rays. More... | |
Scalar | Cross (const SeparatedVector2 &other) const |
Returns the cross product of the two direction vectors. More... | |
Public Attributes | |
Vector2 | direction |
The normalized direction of the vector. More... | |
Scalar | magnitude = 0.0 |
The magnitude of the vector. More... | |
A Vector2, broken down as a separate magnitude and direction. Assumes that the direction given is normalized.
This is a simple convenience struct for handling polyline offset values when generating stroke geometry. For performance reasons, it's sometimes adventageous to track the direction and magnitude for offsets separately.
Definition at line 21 of file separated_vector.h.
|
default |
Definition at line 11 of file separated_vector.cc.
|
explicit |
Definition at line 14 of file separated_vector.cc.
Radians impeller::SeparatedVector2::AngleTo | ( | const SeparatedVector2 & | other | ) | const |
Returns the scalar angle between the two rays.
Definition at line 29 of file separated_vector.cc.
References impeller::TPoint< T >::AngleTo(), and direction.
Referenced by impeller::testing::TEST().
Scalar impeller::SeparatedVector2::Cross | ( | const SeparatedVector2 & | other | ) | const |
Returns the cross product of the two direction vectors.
Definition at line 33 of file separated_vector.cc.
References impeller::TPoint< T >::Cross(), and direction.
Scalar impeller::SeparatedVector2::GetAlignment | ( | const SeparatedVector2 & | other | ) | const |
Returns the scalar alignment of the two vectors. In other words, the dot product of the two normalized vectors.
Range: [-1, 1] A value of 1 indicates the directions are parallel and pointing in the same direction. A value of -1 indicates the vectors are parallel and pointing in opposite directions. A value of 0 indicates the vectors are perpendicular.
Definition at line 25 of file separated_vector.cc.
References direction, and impeller::TPoint< T >::Dot().
Referenced by impeller::StrokePathSegmentReceiver::RecordCurveSegment(), and impeller::testing::TEST().
Vector2 impeller::SeparatedVector2::GetDirection | ( | ) | const |
Returns just the normalized direction vector.
Definition at line 21 of file separated_vector.cc.
References direction.
Vector2 impeller::SeparatedVector2::GetVector | ( | ) | const |
Returns the vector representation of the vector.
Definition at line 17 of file separated_vector.cc.
References direction, and magnitude.
Referenced by impeller::StrokePathSegmentReceiver::EndContour(), and impeller::testing::TEST().
Vector2 impeller::SeparatedVector2::direction |
The normalized direction of the vector.
Definition at line 23 of file separated_vector.h.
Referenced by AngleTo(), Cross(), GetAlignment(), GetDirection(), GetVector(), and impeller::testing::TEST().
Scalar impeller::SeparatedVector2::magnitude = 0.0 |
The magnitude of the vector.
Definition at line 26 of file separated_vector.h.
Referenced by GetVector(), and impeller::testing::TEST().