| 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...
Scalar | GetAlignment (const SeparatedVector2 &other) const
Radians | AngleTo (const SeparatedVector2 &other) const
| Returns the scalar angle between the two rays. 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 25 of file separated_vector.cc.

25 {
26 return direction.AngleTo(other.direction);
27 }
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().

## ◆ 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 21 of file separated_vector.cc.

21 {
22 return direction.Dot(other.direction);
23 }
impeller::TPoint::Dot
constexpr Type Dot(const TPoint &p) const
Definition: point.h:220

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

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

## ◆ 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::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(), GetAlignment(), 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