Gin
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
Ellipse< T > Class Template Reference

Equations to calculate the shape of an ellipse and to calculate points on the edge of the ellipse and to see if points are inside or outside. More...

#include <gin_geometry.h>

Public Member Functions

 Ellipse (T x_, T y_, T a_, T b_)
 Creates a ellipse with a given centre and width / height.
 
 Ellipse (T a_, T b_)
 Creates an ellipse centred at (0,0) with the specified width and height.
 
bool isPointOn (Point< T > pt, T accuracy=0.00001)
 Checks if a point lies on the ellipse boundary.
 
bool isPointOutside (Point< T > pt)
 Checks if a point lies outside the ellipse.
 
bool isPointInside (Point< T > pt)
 Checks if a point lies inside the ellipse.
 
Point< T > pointAtAngle (T angle)
 Calculates the point on the ellipse at the specified angle.
 

Public Attributes

x = 0
 
y = 0
 Centre coordinates of the ellipse.
 
a = 0
 
b = 0
 Semi-major and semi-minor axes (half width and height)
 

Detailed Description

template<typename T>
class Ellipse< T >

Equations to calculate the shape of an ellipse and to calculate points on the edge of the ellipse and to see if points are inside or outside.

Constructor & Destructor Documentation

◆ Ellipse() [1/2]

template<typename T >
Ellipse< T >::Ellipse ( x_,
y_,
a_,
b_ 
)

Creates a ellipse with a given centre and width / height.

◆ Ellipse() [2/2]

template<typename T >
Ellipse< T >::Ellipse ( a_,
b_ 
)

Creates an ellipse centred at (0,0) with the specified width and height.

Parameters
a_Half the width of the ellipse (semi-major axis if a > b)
b_Half the height of the ellipse (semi-minor axis if b < a)

Member Function Documentation

◆ isPointOn()

template<typename T >
bool Ellipse< T >::isPointOn ( Point< T >  pt,
accuracy = 0.00001 
)

Checks if a point lies on the ellipse boundary.

Parameters
ptThe point to test
accuracyTolerance for the test (default: 0.00001)
Returns
true if the point is on the ellipse within the given accuracy

References Ellipse< T >::a, Ellipse< T >::b, Point< T >::getX(), Point< T >::getY(), square, Ellipse< T >::x, Point< T >::x, Ellipse< T >::y, and Point< T >::y.

◆ isPointOutside()

template<typename T >
bool Ellipse< T >::isPointOutside ( Point< T >  pt)

Checks if a point lies outside the ellipse.

Parameters
ptThe point to test
Returns
true if the point is outside the ellipse

References Ellipse< T >::a, Ellipse< T >::b, Point< T >::getX(), Point< T >::getY(), square, Ellipse< T >::x, Point< T >::x, Ellipse< T >::y, and Point< T >::y.

◆ isPointInside()

template<typename T >
bool Ellipse< T >::isPointInside ( Point< T >  pt)

Checks if a point lies inside the ellipse.

Parameters
ptThe point to test
Returns
true if the point is inside the ellipse

References Ellipse< T >::a, Ellipse< T >::b, Point< T >::getX(), Point< T >::getY(), square, Ellipse< T >::x, Point< T >::x, Ellipse< T >::y, and Point< T >::y.

◆ pointAtAngle()

template<typename T >
Point< T > Ellipse< T >::pointAtAngle ( angle)

Calculates the point on the ellipse at the specified angle.

The angle is measured from the positive x-axis, going counter-clockwise.

Parameters
angleThe angle in radians
Returns
The point on the ellipse at that angle

References Ellipse< T >::a, Ellipse< T >::b, square, Ellipse< T >::x, and Ellipse< T >::y.

Member Data Documentation

◆ x

template<typename T >
T Ellipse< T >::x = 0

◆ y

template<typename T >
T Ellipse< T >::y = 0

◆ a

template<typename T >
T Ellipse< T >::a = 0

◆ b

template<typename T >
T Ellipse< T >::b = 0

Semi-major and semi-minor axes (half width and height)

Referenced by Ellipse< T >::isPointInside(), Ellipse< T >::isPointOn(), Ellipse< T >::isPointOutside(), and Ellipse< T >::pointAtAngle().


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