Flutter Impeller
separated_vector.h
Go to the documentation of this file.
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#ifndef FLUTTER_IMPELLER_GEOMETRY_SEPARATED_VECTOR_H_
6
#define FLUTTER_IMPELLER_GEOMETRY_SEPARATED_VECTOR_H_
7
8
#include "
impeller/geometry/point.h
"
9
10
#include "
impeller/geometry/scalar.h
"
11
12
namespace
impeller
{
13
14
/// @brief A Vector2, broken down as a separate magnitude and direction.
15
/// Assumes that the direction given is normalized.
16
///
17
/// This is a simple convenience struct for handling polyline offset
18
/// values when generating stroke geometry. For performance reasons,
19
/// it's sometimes adventageous to track the direction and magnitude
20
/// for offsets separately.
21
struct
SeparatedVector2
{
22
/// The normalized direction of the vector.
23
Vector2
direction
;
24
25
/// The magnitude of the vector.
26
Scalar
magnitude
= 0.0;
27
28
SeparatedVector2
();
29
SeparatedVector2
(
Vector2
direction
,
Scalar
magnitude
);
30
explicit
SeparatedVector2
(
Vector2
vector);
31
32
/// Returns the vector representation of the vector.
33
Vector2
GetVector
()
const
;
34
35
/// Returns the scalar alignment of the two vectors.
36
/// In other words, the dot product of the two normalized vectors.
37
///
38
/// Range: [-1, 1]
39
/// A value of 1 indicates the directions are parallel and pointing in the
40
/// same direction. A value of -1 indicates the vectors are parallel and
41
/// pointing in opposite directions. A value of 0 indicates the vectors are
42
/// perpendicular.
43
Scalar
GetAlignment
(
const
SeparatedVector2
& other)
const
;
44
45
/// Returns the scalar angle between the two rays.
46
Radians
AngleTo
(
const
SeparatedVector2
& other)
const
;
47
};
48
49
#endif // FLUTTER_IMPELLER_GEOMETRY_SEPARATED_VECTOR_H_
50
51
}
// namespace impeller
point.h
impeller::Scalar
float Scalar
Definition:
scalar.h:18
impeller::SeparatedVector2
A Vector2, broken down as a separate magnitude and direction. Assumes that the direction given is nor...
Definition:
separated_vector.h:21
impeller::SeparatedVector2::magnitude
Scalar magnitude
The magnitude of the vector.
Definition:
separated_vector.h:26
impeller::SeparatedVector2::direction
Vector2 direction
The normalized direction of the vector.
Definition:
separated_vector.h:23
impeller::SeparatedVector2::GetVector
Vector2 GetVector() const
Returns the vector representation of the vector.
Definition:
separated_vector.cc:17
impeller::SeparatedVector2::GetAlignment
Scalar GetAlignment(const SeparatedVector2 &other) const
Definition:
separated_vector.cc:21
impeller::Radians
Definition:
scalar.h:38
scalar.h
impeller::TPoint< Scalar >
impeller::SeparatedVector2::AngleTo
Radians AngleTo(const SeparatedVector2 &other) const
Returns the scalar angle between the two rays.
Definition:
separated_vector.cc:25
impeller::SeparatedVector2::SeparatedVector2
SeparatedVector2()
impeller
Definition:
aiks_blend_unittests.cc:18
impeller
geometry
separated_vector.h
Generated by
1.8.17