Flutter Impeller
impeller::Trig Struct Reference

A structure to store the sine and cosine of an angle. More...

#include <trig.h>

Public Member Functions

 Trig (Radians r)
 Construct a Trig object from a given angle in radians. More...
 
 Trig (double cos, double sin)
 Construct a Trig object from the given cosine and sine values. More...
 
Vector2 operator* (const Vector2 &vector) const
 Returns the vector rotated by the represented angle. More...
 
Trig operator- () const
 Returns the Trig representing the negative version of this angle. More...
 
Vector2 operator* (double radius) const
 Returns the corresponding point on a circle of a given |radius|. More...
 
Vector2 operator* (const Size &ellipse_radii) const
 Returns the corresponding point on an ellipse with the given size. More...
 

Public Attributes

double cos
 
double sin
 

Detailed Description

A structure to store the sine and cosine of an angle.

Definition at line 16 of file trig.h.

Constructor & Destructor Documentation

◆ Trig() [1/2]

impeller::Trig::Trig ( Radians  r)
inlineexplicit

Construct a Trig object from a given angle in radians.

Definition at line 18 of file trig.h.

19  : cos(std::cos(r.radians)), sin(std::sin(r.radians)) {}
double cos
Definition: trig.h:24
double sin
Definition: trig.h:25

Referenced by operator-().

◆ Trig() [2/2]

impeller::Trig::Trig ( double  cos,
double  sin 
)
inline

Construct a Trig object from the given cosine and sine values.

Definition at line 22 of file trig.h.

22 : cos(cos), sin(sin) {}

Member Function Documentation

◆ operator*() [1/3]

Vector2 impeller::Trig::operator* ( const Size ellipse_radii) const
inline

Returns the corresponding point on an ellipse with the given size.

Definition at line 43 of file trig.h.

43  {
44  return Vector2(static_cast<Scalar>(cos * ellipse_radii.width),
45  static_cast<Scalar>(sin * ellipse_radii.height));
46  }
Point Vector2
Definition: point.h:331
float Scalar
Definition: scalar.h:19

References cos, impeller::TSize< T >::height, sin, and impeller::TSize< T >::width.

◆ operator*() [2/3]

Vector2 impeller::Trig::operator* ( const Vector2 vector) const
inline

Returns the vector rotated by the represented angle.

Definition at line 28 of file trig.h.

28  {
29  return Vector2(static_cast<Scalar>(vector.x * cos - vector.y * sin),
30  static_cast<Scalar>(vector.x * sin + vector.y * cos));
31  }

References cos, sin, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator*() [3/3]

Vector2 impeller::Trig::operator* ( double  radius) const
inline

Returns the corresponding point on a circle of a given |radius|.

Definition at line 37 of file trig.h.

37  {
38  return Vector2(static_cast<Scalar>(cos * radius),
39  static_cast<Scalar>(sin * radius));
40  }

References cos, and sin.

◆ operator-()

Trig impeller::Trig::operator- ( ) const
inline

Returns the Trig representing the negative version of this angle.

Definition at line 34 of file trig.h.

34 { return Trig(cos, -sin); }
Trig(Radians r)
Construct a Trig object from a given angle in radians.
Definition: trig.h:18

References cos, sin, and Trig().

Member Data Documentation

◆ cos

double impeller::Trig::cos

Definition at line 24 of file trig.h.

Referenced by operator*(), operator-(), and impeller::testing::TEST().

◆ sin

double impeller::Trig::sin

Definition at line 25 of file trig.h.

Referenced by operator*(), operator-(), and impeller::testing::TEST().


The documentation for this struct was generated from the following file: