| Flutter Impeller |

trig.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_TRIG_H_
6 #define FLUTTER_IMPELLER_GEOMETRY_TRIG_H_
7
8 #include <functional>
9 #include <vector>
10
11 #include "flutter/impeller/geometry/point.h"
12
13 namespace impeller {
14
15 /// @brief A structure to store the sine and cosine of an angle.
16 struct Trig {
17 /// Construct a Trig object from a given angle in radians.
18 explicit Trig(Radians r)
19 : cos(std::cos(r.radians)), sin(std::sin(r.radians)) {}
20
21 /// Construct a Trig object from the given cosine and sine values.
22 Trig(double cos, double sin) : cos(cos), sin(sin) {}
23
24 double cos;
25 double sin;
26
27 /// @brief Returns the corresponding point on a circle of a given |radius|.
28 Vector2 operator*(double radius) const {
29 return Vector2(static_cast<Scalar>(cos * radius),
30 static_cast<Scalar>(sin * radius));
31 }
32
33 /// @brief Returns the corresponding point on an ellipse with the given size.
34 Vector2 operator*(const Size& ellipse_radii) const {
35 return Vector2(static_cast<Scalar>(cos * ellipse_radii.width),
36 static_cast<Scalar>(sin * ellipse_radii.height));
37 }
38 };
39
40 } // namespace impeller
41
42 #endif // FLUTTER_IMPELLER_GEOMETRY_TRIG_H_
point.h
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::Trig::operator*
Vector2 operator*(const Size &ellipse_radii) const
Returns the corresponding point on an ellipse with the given size.
Definition: trig.h:34
impeller::Trig::operator*
Vector2 operator*(double radius) const
Returns the corresponding point on a circle of a given |radius|.
Definition: trig.h:28
impeller::Trig::Trig
Trig(Radians r)
Construct a Trig object from a given angle in radians.
Definition: trig.h:18
impeller::Vector2
Point Vector2
Definition: point.h:320
impeller::Trig::Trig
Trig(double cos, double sin)
Construct a Trig object from the given cosine and sine values.
Definition: trig.h:22
impeller::TSize< Scalar >
impeller::Trig::cos
double cos
Definition: trig.h:24
impeller::Radians
Definition: scalar.h:38
impeller::TSize::width
Type width
Definition: size.h:22
std
Definition: comparable.h:95
impeller::TPoint< Scalar >
impeller::TSize::height
Type height
Definition: size.h:23
impeller
Definition: aiks_blur_unittests.cc:20
impeller::Trig::sin
double sin
Definition: trig.h:25
impeller::Trig
A structure to store the sine and cosine of an angle.
Definition: trig.h:16