Flutter Engine
The Flutter Engine
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.

Vector2 direction
The normalized direction of the vector.
Scalar magnitude
The magnitude of the vector.

◆ 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}
constexpr Radians AngleTo(const TPoint &p) const
Definition: point.h:232

◆ 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}
constexpr Type Dot(const TPoint &p) const
Definition: point.h:220

◆ 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}

Member Data Documentation

◆ direction

Vector2 impeller::SeparatedVector2::direction

The normalized direction of the vector.

Definition at line 23 of file separated_vector.h.

◆ magnitude

Scalar impeller::SeparatedVector2::magnitude = 0.0

The magnitude of the vector.

Definition at line 26 of file separated_vector.h.


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