Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Geom::Angle Class Reference

Wrapper for angular values. More...

#include <angle.h>

Inheritance diagram for Geom::Angle:

Public Member Functions

 Angle ()
 
 Angle (Coord v)
 
 Angle (Point const &p)
 
 Angle (Point const &a, Point const &b)
 
 operator Coord () const
 
Angleoperator+= (Angle o)
 
Angleoperator-= (Angle o)
 
Angleoperator+= (Coord a)
 
Angleoperator-= (Coord a)
 
bool operator== (Angle o) const
 
bool operator== (Coord c) const
 
Coord radians () const
 Get the angle as radians.
 
Coord radians0 () const
 Get the angle as positive radians.
 
Coord degrees () const
 Get the angle as degrees in math convention.
 
Coord degreesClock () const
 Get the angle as degrees in clock convention.
 

Static Public Member Functions

static Angle from_radians (Coord d)
 Create an angle from its measure in radians.
 
static Angle from_degrees (Coord d)
 Create an angle from its measure in degrees.
 
static Angle from_degrees_clock (Coord d)
 Create an angle from its measure in degrees in clock convention.
 

Private Member Functions

void _normalize ()
 

Private Attributes

Coord _angle
 

Friends

class AngleInterval
 

Related Symbols

(Note that these are not member symbols.)

constexpr Coord rad_from_deg (Coord deg)
 Given an angle in degrees, return radians.
 
constexpr Coord deg_from_rad (Coord rad)
 Given an angle in radians, return degrees.
 

Detailed Description

Wrapper for angular values.

This class is a convenience wrapper that implements the behavior generally expected of angles, like addition modulo \(2\pi\). The value returned from the default conversion to double is in the range \([-\pi, \pi)\) - the convention used by C's math library.

This class holds only a single floating point value, so passing it by value will generally be faster than passing it by const reference.

Definition at line 67 of file angle.h.

Constructor & Destructor Documentation

◆ Angle() [1/4]

Geom::Angle::Angle ( )
inline

Definition at line 75 of file angle.h.

Referenced by operator+=(), operator-=(), and operator==().

◆ Angle() [2/4]

Geom::Angle::Angle ( Coord  v)
inline

Definition at line 76 of file angle.h.

References _normalize().

◆ Angle() [3/4]

Geom::Angle::Angle ( Point const &  p)
inlineexplicit

Definition at line 77 of file angle.h.

References _normalize().

◆ Angle() [4/4]

Geom::Angle::Angle ( Point const &  a,
Point const &  b 
)
inline

Definition at line 78 of file angle.h.

References _normalize().

Member Function Documentation

◆ _normalize()

void Geom::Angle::_normalize ( )
inlineprivate

Definition at line 154 of file angle.h.

References _angle.

Referenced by Angle(), Angle(), Angle(), operator+=(), and operator-=().

◆ degrees()

Coord Geom::Angle::degrees ( ) const
inline

Get the angle as degrees in math convention.

Returns
Number in range [-180, 180) obtained by scaling the result of radians() by \(180/\pi\).

Definition at line 118 of file angle.h.

References radians().

Referenced by radians_to_degree_mod360().

◆ degreesClock()

Coord Geom::Angle::degreesClock ( ) const
inline

Get the angle as degrees in clock convention.

This method converts the angle to the "clock convention": angles start from the +Y axis and grow clockwise. This means that 0 corresponds to \(\pi/2\) radians, 90 to 0 radians, 180 to \(-\pi/2\) radians, and 270 to \(\pi\) radians.

Returns
A number in the range [0, 360).

Definition at line 125 of file angle.h.

References _angle.

◆ from_degrees()

◆ from_degrees_clock()

static Angle Geom::Angle::from_degrees_clock ( Coord  d)
inlinestatic

Create an angle from its measure in degrees in clock convention.

See also
Angle::degreesClock()

Definition at line 142 of file angle.h.

References _angle.

◆ from_radians()

static Angle Geom::Angle::from_radians ( Coord  d)
inlinestatic

Create an angle from its measure in radians.

Definition at line 131 of file angle.h.

Referenced by radians_to_degree_mod360().

◆ operator Coord()

Geom::Angle::operator Coord ( ) const
inline

Definition at line 79 of file angle.h.

References radians().

◆ operator+=() [1/2]

Angle & Geom::Angle::operator+= ( Angle  o)
inline

Definition at line 80 of file angle.h.

References _angle, and _normalize().

◆ operator+=() [2/2]

Angle & Geom::Angle::operator+= ( Coord  a)
inline

Definition at line 90 of file angle.h.

References Angle().

◆ operator-=() [1/2]

Angle & Geom::Angle::operator-= ( Angle  o)
inline

Definition at line 85 of file angle.h.

References _angle, and _normalize().

◆ operator-=() [2/2]

Angle & Geom::Angle::operator-= ( Coord  a)
inline

Definition at line 94 of file angle.h.

References Angle().

◆ operator==() [1/2]

bool Geom::Angle::operator== ( Angle  o) const
inline

Definition at line 98 of file angle.h.

References _angle.

◆ operator==() [2/2]

bool Geom::Angle::operator== ( Coord  c) const
inline

Definition at line 101 of file angle.h.

References _angle, Angle(), and c.

◆ radians()

Coord Geom::Angle::radians ( ) const
inline

Get the angle as radians.

Returns
Number in range \([-\pi, \pi)\).

Definition at line 107 of file angle.h.

References _angle.

Referenced by degree_to_radians_mod2pi(), degrees(), operator Coord(), Geom::Ellipse::operator*=(), and Geom::EllipticalArc::toSBasis().

◆ radians0()

Friends And Related Symbol Documentation

◆ AngleInterval

friend class AngleInterval
friend

Definition at line 160 of file angle.h.

◆ deg_from_rad()

constexpr Coord deg_from_rad ( Coord  rad)
related

Given an angle in radians, return degrees.

Definition at line 389 of file angle.h.

◆ rad_from_deg()

constexpr Coord rad_from_deg ( Coord  deg)
related

Given an angle in degrees, return radians.

Definition at line 386 of file angle.h.

Member Data Documentation

◆ _angle

Coord Geom::Angle::_angle
private

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