| Flutter Impeller |

separated_vector.cc
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 #include "separated_vector.h"
6
7 namespace impeller {
8
9 SeparatedVector2::SeparatedVector2() = default;
10
11 SeparatedVector2::SeparatedVector2(Vector2 direction, Scalar magnitude)
12 : direction(direction), magnitude(magnitude){};
13
14 SeparatedVector2::SeparatedVector2(Vector2 vector)
15 : direction(vector.Normalize()), magnitude(vector.GetLength()){};
16
17 Vector2 SeparatedVector2::GetVector() const {
18 return direction * magnitude;
19 }
20
21 Scalar SeparatedVector2::GetAlignment(const SeparatedVector2& other) const {
22 return direction.Dot(other.direction);
23 }
24
25 Radians SeparatedVector2::AngleTo(const SeparatedVector2& other) const {
26 return direction.AngleTo(other.direction);
27 }
28
29 } // namespace impeller
impeller
Definition: allocation.cc:12
impeller::Scalar
float Scalar
Definition: scalar.h:18
separated_vector.h
impeller::Radians
Definition: scalar.h:43
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::AngleTo
Radians AngleTo(const SeparatedVector2 &other) const
Returns the scalar angle between the two rays.
Definition: separated_vector.cc:25
impeller::SeparatedVector2::GetAlignment
Scalar GetAlignment(const SeparatedVector2 &other) const
Definition: separated_vector.cc:21
impeller::SeparatedVector2::direction
Vector2 direction
The normalized direction of the vector.
Definition: separated_vector.h:23
impeller::SeparatedVector2::SeparatedVector2
SeparatedVector2()
impeller::SeparatedVector2::GetVector
Vector2 GetVector() const
Returns the vector representation of the vector.
Definition: separated_vector.cc:17
impeller::SeparatedVector2::magnitude
Scalar magnitude
The magnitude of the vector.
Definition: separated_vector.h:26
impeller::TPoint< Scalar >
impeller::TPoint::Dot
constexpr Type Dot(const TPoint &p) const
Definition: point.h:220
impeller::TPoint::AngleTo
constexpr Radians AngleTo(const TPoint &p) const
Definition: point.h:232