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

Directed angular interval. More...

#include <angle.h>

Inheritance diagram for Geom::AngleInterval:

Public Member Functions

 AngleInterval ()
 
 AngleInterval (Angle s, Angle e, bool cw=false)
 Create an angular interval from two angles and direction.
 
 AngleInterval (double s, double e, bool cw=false)
 
 AngleInterval (Angle s, Angle inner, Angle e)
 Create an angular interval from three angles.
 
Angle initialAngle () const
 Get the start angle.
 
Angle finalAngle () const
 Get the end angle.
 
bool sweep () const
 Check whether the interval goes in the direction of increasing angles.
 
bool isDegenerate () const
 Check whether the interval contains only a single angle.
 
bool isFull () const
 Check whether the interval contains all angles.
 
void setInitial (Angle a, bool prefer_full=false)
 Set the initial angle.
 
void setFinal (Angle a, bool prefer_full=false)
 Set the final angle.
 
void setAngles (Angle s, Angle e, bool prefer_full=false)
 Set both angles at once.
 
void setSweep (bool s)
 Set whether the interval goes in the direction of increasing angles.
 
void reverse ()
 Reverse the direction of the interval while keeping contained values the same.
 
AngleInterval reversed () const
 Get a new interval with reversed direction.
 
Angle angleAt (Coord t) const
 Get an angle corresponding to the specified time value.
 
Angle operator() (Coord t) const
 
Coord timeAtAngle (Angle a) const
 Compute a time value that would evaluate to the given angle.
 
bool contains (Angle a) const
 Check whether the interval includes the given angle.
 
Coord extent () const
 Extent of the angle interval.
 
Coord sweepAngle () const
 Get the sweep angle of the interval.
 
bool operator== (AngleInterval const &other) const
 Check another interval for equality.
 

Static Public Member Functions

static AngleInterval create_full (Angle start, bool sweep=true)
 

Private Attributes

Angle _start_angle
 
Angle _end_angle
 
bool _sweep
 
bool _full
 

Detailed Description

Directed angular interval.

Wrapper for directed angles with defined start and end values. Useful e.g. for representing the portion of an ellipse in an elliptical arc. Both extreme angles are contained in the interval (it is a closed interval). Angular intervals can also be interptered as functions \(f: [0, 1] \to [-\pi, \pi)\), which return the start angle for 0, the end angle for 1, and interpolate linearly for other values. Note that such functions are not continuous if the interval crosses the angle \(\pi\).

This class can represent all directed angular intervals, including empty ones. However, not all possible intervals can be created with the constructors. For full control, use the setInitial(), setFinal() and setAngles() methods.

Definition at line 186 of file angle.h.

Constructor & Destructor Documentation

◆ AngleInterval() [1/4]

Geom::AngleInterval::AngleInterval ( )
inline

Definition at line 190 of file angle.h.

◆ AngleInterval() [2/4]

Geom::AngleInterval::AngleInterval ( Angle  s,
Angle  e,
bool  cw = false 
)
inline

Create an angular interval from two angles and direction.

If the initial and final angle are the same, a degenerate interval (containing only one angle) will be created.

Parameters
sStarting angle
eEnding angle
cwWhich direction the interval goes. True means that it goes in the direction of increasing angles, while false means in the direction of decreasing angles.

Definition at line 199 of file angle.h.

◆ AngleInterval() [3/4]

Geom::AngleInterval::AngleInterval ( double  s,
double  e,
bool  cw = false 
)
inline

Definition at line 202 of file angle.h.

◆ AngleInterval() [4/4]

Geom::AngleInterval::AngleInterval ( Angle  s,
Angle  inner,
Angle  e 
)
inline

Create an angular interval from three angles.

If the inner angle is exactly equal to initial or final angle, the sweep flag will be set to true, i.e. the interval will go in the direction of increasing angles.

If the initial and final angle are the same, but the inner angle is different, a full angle in the direction of increasing angles will be created.

Parameters
sInitial angle
innerAngle contained in the interval
eFinal angle

Definition at line 217 of file angle.h.

References _full, and _sweep.

Member Function Documentation

◆ angleAt()

Angle Geom::AngleInterval::angleAt ( Coord  t) const
inline

Get an angle corresponding to the specified time value.

Definition at line 288 of file angle.h.

References _start_angle, _sweep, extent(), and Geom::Angle::radians0().

Referenced by Geom::EllipticalArc::angleAt(), Geom::make_angle_bisector_line(), operator()(), and TEST().

◆ contains()

bool Geom::AngleInterval::contains ( Angle  a) const
inline

◆ create_full()

static AngleInterval Geom::AngleInterval::create_full ( Angle  start,
bool  sweep = true 
)
inlinestatic

Definition at line 369 of file angle.h.

References _start_angle, result, start, and sweep().

Referenced by TEST(), TEST(), and TEST().

◆ extent()

Coord Geom::AngleInterval::extent ( ) const
inline

Extent of the angle interval.

Equivalent to the absolute value of the sweep angle.

Returns
Extent in range \([0, 2\pi)\).

Definition at line 342 of file angle.h.

References _end_angle, _full, _start_angle, and _sweep.

Referenced by SPGenericEllipse::_isSlice(), angleAt(), Geom::EllipticalArc::angularExtent(), TEST(), TEST(), TEST(), TEST(), and timeAtAngle().

◆ finalAngle()

Angle Geom::AngleInterval::finalAngle ( ) const
inline

Get the end angle.

Definition at line 231 of file angle.h.

References _end_angle.

Referenced by Geom::EllipticalArc::_intersectSameEllipse(), Geom::EllipticalArc::finalAngle(), and SPGenericEllipse::normalize().

◆ initialAngle()

Angle Geom::AngleInterval::initialAngle ( ) const
inline

Get the start angle.

Definition at line 229 of file angle.h.

References _start_angle.

Referenced by Geom::EllipticalArc::_intersectSameEllipse(), Geom::EllipticalArc::initialAngle(), and SPGenericEllipse::normalize().

◆ isDegenerate()

bool Geom::AngleInterval::isDegenerate ( ) const
inline

Check whether the interval contains only a single angle.

Definition at line 235 of file angle.h.

References _end_angle, _full, and _start_angle.

◆ isFull()

bool Geom::AngleInterval::isFull ( ) const
inline

Check whether the interval contains all angles.

Definition at line 239 of file angle.h.

References _end_angle, _full, and _start_angle.

Referenced by Geom::EllipticalArc::boundsExact(), Geom::EllipticalArc::expandToTransformed(), and Geom::EllipticalArc::winding().

◆ operator()()

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

Definition at line 293 of file angle.h.

References angleAt().

◆ operator==()

bool Geom::AngleInterval::operator== ( AngleInterval const &  other) const
inline

Check another interval for equality.

Definition at line 361 of file angle.h.

References _end_angle, _full, _start_angle, and _sweep.

◆ reverse()

void Geom::AngleInterval::reverse ( )
inline

Reverse the direction of the interval while keeping contained values the same.

Definition at line 275 of file angle.h.

References _end_angle, _start_angle, and _sweep.

Referenced by Geom::EllipticalArc::reverse().

◆ reversed()

AngleInterval Geom::AngleInterval::reversed ( ) const
inline

Get a new interval with reversed direction.

Definition at line 281 of file angle.h.

References result.

◆ setAngles()

void Geom::AngleInterval::setAngles ( Angle  s,
Angle  e,
bool  prefer_full = false 
)
inline

Set both angles at once.

The direction (sweep flag) is left unchanged.

Parameters
sInitial angle
eFinal angle
prefer_fullWhether to set a full interval when the passed initial and final angle are the same

Definition at line 266 of file angle.h.

References _end_angle, _full, and _start_angle.

Referenced by Geom::EllipticalArc::_updateCenterAndAngles(), and Geom::EllipticalArc::portion().

◆ setFinal()

void Geom::AngleInterval::setFinal ( Angle  a,
bool  prefer_full = false 
)
inline

Set the final angle.

Parameters
aAngle to set
prefer_fullWhether to set a full angular interval when the initial angle is set to the final angle

Definition at line 256 of file angle.h.

References _end_angle, _full, and _start_angle.

Referenced by Geom::EllipticalArc::_updateCenterAndAngles(), and Geom::EllipticalArc::operator*=().

◆ setInitial()

void Geom::AngleInterval::setInitial ( Angle  a,
bool  prefer_full = false 
)
inline

Set the initial angle.

Parameters
aAngle to set
prefer_fullWhether to set a full angular interval when the initial angle is set to the final angle

Definition at line 247 of file angle.h.

References _end_angle, _full, and _start_angle.

Referenced by Geom::EllipticalArc::_updateCenterAndAngles(), and Geom::EllipticalArc::operator*=().

◆ setSweep()

void Geom::AngleInterval::setSweep ( bool  s)
inline

Set whether the interval goes in the direction of increasing angles.

Definition at line 272 of file angle.h.

References _sweep.

Referenced by Geom::EllipticalArc::_updateCenterAndAngles(), Geom::EllipticalArc::operator*=(), Geom::EllipticalArc::portion(), Geom::EllipticalArc::set(), and Geom::EllipticalArc::set().

◆ sweep()

bool Geom::AngleInterval::sweep ( ) const
inline

Check whether the interval goes in the direction of increasing angles.

Definition at line 233 of file angle.h.

References _sweep.

Referenced by create_full(), and Geom::EllipticalArc::sweep().

◆ sweepAngle()

Coord Geom::AngleInterval::sweepAngle ( ) const
inline

Get the sweep angle of the interval.

This is the value you need to add to the initial angle to get the final angle. It is positive when sweep is true. Denoted as \(\Delta\theta\) in the SVG elliptical arc implementation notes.

Definition at line 352 of file angle.h.

References _end_angle, _full, _start_angle, _sweep, and Geom::Angle::radians0().

Referenced by Geom::EllipticalArc::sweepAngle(), and TEST().

◆ timeAtAngle()

Coord Geom::AngleInterval::timeAtAngle ( Angle  a) const
inline

Compute a time value that would evaluate to the given angle.

If the start and end angle are exactly the same, NaN will be returned. Negative values will be returned for angles between the initial angle and the angle exactly opposite the midpoint of the interval.

Definition at line 299 of file angle.h.

References _full, _start_angle, _sweep, extent(), and Geom::Angle::radians0().

Referenced by TEST(), and Geom::EllipticalArc::timeAtAngle().

Member Data Documentation

◆ _end_angle

Angle Geom::AngleInterval::_end_angle
private

◆ _full

bool Geom::AngleInterval::_full
private

◆ _start_angle

Angle Geom::AngleInterval::_start_angle
private

◆ _sweep

bool Geom::AngleInterval::_sweep
private

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