Core 1.0
Public Member Functions | Protected Attributes | Friends | List of all members
Ellipse2 Class Reference

Axis aligned ellipses. More...

#include <ellipse.h>

Public Member Functions

 Ellipse2 ()
 Empty.
 
 Ellipse2 (const Vector2 &, const double &, const double &)
 Create an ellipse. More...
 
 ~Ellipse2 ()
 Empty.
 
Vector2 Center () const
 Gets the center.
 
double A () const
 Major radius of the ellipse.
 
double B () const
 Minor radius of the ellipse.
 
Vector2 Vertex (const double &) const
 Compute a vertex on the ellipse. More...
 
double Curvature (const double &) const
 Compute the curvature at a vertex on the ellipse. More...
 
bool Inside (const Vector2 &) const
 Check if a point is inside the circle. More...
 
double R (const Vector2 &) const
 Compute the squared distance between a point and the ellipse. More...
 
double Signed (const Vector2 &) const
 Compute the signed distance between a point and the ellipse. More...
 
Ellipse2 Translated (const Vector2 &) const
 Translate an ellipse. More...
 
Ellipse2 Scaled (const double &) const
 Scales an ellipse. More...
 
Ellipse2 Scaled (const Vector2 &) const
 Scales an ellipse. More...
 
double Eccentricity () const
 Eccentricity.
 
double Focus () const
 Area of an ellipse.
 
Box2 GetBox () const
 Compute the bounding box.
 
double Area () const
 Area of an ellipse.
 
double Perimeter () const
 Perimeter of an ellipse. More...
 
Vector2 RandomInside (Random &=Random::R239) const
 Generate a random vector inside the circle. More...
 
void Draw (QGraphicsScene &, const QPen &, const QBrush &) const
 Draw a circle. More...
 
double Value (const Vector2 &) const
 Compute the field function value of an ellipse. More...
 
Vector2 Gradient (const Vector2 &) const
 Compute the gradient of the field function. More...
 

Protected Attributes

Vector2 c
 Center of the ellipse.
 
double b = 1.0
 Axes lengths.
 

Friends

std::ostream & operator<< (std::ostream &, const Ellipse2 &)
 Overloaded. More...
 

Detailed Description

Axis aligned ellipses.

See also
Circle2

Constructor & Destructor Documentation

◆ Ellipse2()

Ellipse2::Ellipse2 ( const Vector2 c,
const double &  a,
const double &  b 
)
explicit

Create an ellipse.

Parameters
cCenter.
a,bAxes lengths.

Member Function Documentation

◆ Curvature()

double Ellipse2::Curvature ( const double &  t) const

Compute the curvature at a vertex on the ellipse.

Parameters
tAngle.

◆ Draw()

void Ellipse2::Draw ( QGraphicsScene &  scene,
const QPen &  pen,
const QBrush &  brush 
) const

Draw a circle.

Parameters
sceneGraphics scene.
penThe pen.
brushThe brush, should the circle be filled.

◆ Gradient()

Vector2 Ellipse2::Gradient ( const Vector2 p) const

Compute the gradient of the field function.

Parameters
pPoint.

◆ Inside()

bool Ellipse2::Inside ( const Vector2 p) const

Check if a point is inside the circle.

Parameters
pPoint.

◆ Perimeter()

double Ellipse2::Perimeter ( ) const

Perimeter of an ellipse.

The exact perimeter of an ellipse is 4 a E(e) where e is the eccentricity, and the function E is the complete elliptic integral of the second kind.

Here we use an approximation of Srinivasa Ramanujan, Modular Equations and Approximations to pi, that gives close approximations.

◆ R()

double Ellipse2::R ( const Vector2 p) const

Compute the squared distance between a point and the ellipse.

Parameters
pPoint.

◆ RandomInside()

Vector2 Ellipse2::RandomInside ( Random random = Random::R239) const

Generate a random vector inside the circle.

Parameters
randomRandom number generator.

◆ Scaled() [1/2]

Ellipse2 Ellipse2::Scaled ( const double &  s) const

Scales an ellipse.

Parameters
sScaling factor.

◆ Scaled() [2/2]

Ellipse2 Ellipse2::Scaled ( const Vector2 s) const

Scales an ellipse.

Parameters
sScaling vector.

◆ Signed()

double Ellipse2::Signed ( const Vector2 p) const

Compute the signed distance between a point and the ellipse.

Parameters
pPoint.

◆ Translated()

Ellipse2 Ellipse2::Translated ( const Vector2 t) const

Translate an ellipse.

Parameters
tTranslation vector.

◆ Value()

double Ellipse2::Value ( const Vector2 p) const

Compute the field function value of an ellipse.

Parameters
pPoint.

◆ Vertex()

Vector2 Ellipse2::Vertex ( const double &  t) const

Compute a vertex on the ellipse.

Parameters
tAngle.

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  s,
const Ellipse2 ellipse 
)
friend

Overloaded.

Parameters
sStream.
ellipseThe ellipse.