Flutter Engine
The Flutter Engine
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
9
11
12namespace 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.
22 /// The normalized direction of the vector.
24
25 /// The magnitude of the vector.
27
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
float Scalar
Definition: scalar.h:18
A Vector2, broken down as a separate magnitude and direction. Assumes that the direction given is nor...
Radians AngleTo(const SeparatedVector2 &other) const
Returns the scalar angle between the two rays.
Scalar GetAlignment(const SeparatedVector2 &other) const
Vector2 direction
The normalized direction of the vector.
Vector2 GetVector() const
Returns the vector representation of the vector.
Scalar magnitude
The magnitude of the vector.