Core 1.0
|
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... | |
Axis aligned ellipses.
|
explicit |
Create an ellipse.
c | Center. |
a,b | Axes lengths. |
double Ellipse2::Curvature | ( | const double & | t | ) | const |
Compute the curvature at a vertex on the ellipse.
t | Angle. |
void Ellipse2::Draw | ( | QGraphicsScene & | scene, |
const QPen & | pen, | ||
const QBrush & | brush | ||
) | const |
Draw a circle.
scene | Graphics scene. |
pen | The pen. |
brush | The brush, should the circle be filled. |
Compute the gradient of the field function.
p | Point. |
bool Ellipse2::Inside | ( | const Vector2 & | p | ) | const |
Check if a point is inside the circle.
p | Point. |
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.
double Ellipse2::R | ( | const Vector2 & | p | ) | const |
Compute the squared distance between a point and the ellipse.
p | Point. |
Vector2 Ellipse2::RandomInside | ( | Random & | random = Random::R239 | ) | const |
Generate a random vector inside the circle.
random | Random number generator. |
Ellipse2 Ellipse2::Scaled | ( | const double & | s | ) | const |
Scales an ellipse.
s | Scaling factor. |
double Ellipse2::Signed | ( | const Vector2 & | p | ) | const |
Compute the signed distance between a point and the ellipse.
p | Point. |
Translate an ellipse.
t | Translation vector. |
double Ellipse2::Value | ( | const Vector2 & | p | ) | const |
Compute the field function value of an ellipse.
p | Point. |
Vector2 Ellipse2::Vertex | ( | const double & | t | ) | const |
Compute a vertex on the ellipse.
t | Angle. |
|
friend |
Overloaded.
s | Stream. |
ellipse | The ellipse. |