| Flutter Impeller |

Public Member Functions | Public Attributes | List of all members
impeller::SeparatedVector2 Struct Reference

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...

## Detailed Description

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.

## Constructor & Destructor Documentation

## ◆ SeparatedVector2() [1/3]

impeller::SeparatedVector2::SeparatedVector2 | ( |  | ) |
| default

## ◆ SeparatedVector2() [2/3]

impeller::SeparatedVector2::SeparatedVector2 | ( | Vector2 | direction,
|  | Scalar | magnitude
| ) |  |

Definition at line 11 of file separated_vector.cc.

12 : direction(direction), magnitude(magnitude){};
impeller::SeparatedVector2::direction
Vector2 direction
The normalized direction of the vector.
Definition: separated_vector.h:23
impeller::SeparatedVector2::magnitude
Scalar magnitude
The magnitude of the vector.
Definition: separated_vector.h:26

## ◆ SeparatedVector2() [3/3]

impeller::SeparatedVector2::SeparatedVector2 | ( | Vector2 | vector | ) |
| explicit

Definition at line 14 of file separated_vector.cc.

15 : direction(vector.Normalize()), magnitude(vector.GetLength()){};

## Member Function Documentation

## ◆ AngleTo()

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.

29 {
30 return direction.AngleTo(other.direction);
31 }
impeller::TPoint::AngleTo
constexpr Radians AngleTo(const TPoint &p) const
Definition: point.h:232

References impeller::TPoint< T >::AngleTo(), and direction.

Referenced by impeller::testing::TEST().

## ◆ Cross()

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.

33 {
34 return direction.Cross(other.direction);
35 }
impeller::TPoint::Cross
constexpr Type Cross(const TPoint &p) const
Definition: point.h:218

References impeller::TPoint< T >::Cross(), and direction.

## ◆ GetAlignment()

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.

25 {
26 return direction.Dot(other.direction);
27 }
impeller::TPoint::Dot
constexpr Type Dot(const TPoint &p) const
Definition: point.h:220

References direction, and impeller::TPoint< T >::Dot().

Referenced by impeller::StrokePathSegmentReceiver::RecordCurveSegment(), and impeller::testing::TEST().

## ◆ GetDirection()

Vector2 impeller::SeparatedVector2::GetDirection | ( |  | ) | const

Returns just the normalized direction vector.

Definition at line 21 of file separated_vector.cc.

21 {
22 return direction;
23 }

References direction.

## ◆ GetVector()

Vector2 impeller::SeparatedVector2::GetVector | ( |  | ) | const

Returns the vector representation of the vector.

Definition at line 17 of file separated_vector.cc.

17 {
18 return direction * magnitude;
19 }

References direction, and magnitude.

Referenced by impeller::StrokePathSegmentReceiver::EndContour(), and impeller::testing::TEST().

## Member Data Documentation

## ◆ direction

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().

## ◆ magnitude

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().

The documentation for this struct was generated from the following files:

- impeller/geometry/separated_vector.h
- impeller/geometry/separated_vector.cc