Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
13namespace impeller {
14
15/// @brief A structure to store the sine and cosine of an angle.
16struct 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 Vector2
Definition point.h:320
float Scalar
Definition scalar.h:18
Definition ref_ptr.h:256
Type height
Definition size.h:23
Type width
Definition size.h:22
A structure to store the sine and cosine of an angle.
Definition trig.h:16
Vector2 operator*(double radius) const
Returns the corresponding point on a circle of a given |radius|.
Definition trig.h:28
Trig(double cos, double sin)
Construct a Trig object from the given cosine and sine values.
Definition trig.h:22
Trig(Radians r)
Construct a Trig object from a given angle in radians.
Definition trig.h:18
double cos
Definition trig.h:24
Vector2 operator*(const Size &ellipse_radii) const
Returns the corresponding point on an ellipse with the given size.
Definition trig.h:34
double sin
Definition trig.h:25