Core 1.0
|
Circles. More...
#include <circle.h>
Public Member Functions | |
Circle () | |
Empty. | |
Circle (const double &) | |
Creates a circle. More... | |
Circle (const Vector &, const Vector &, const double &) | |
Creates a circle. More... | |
Circle (const Vector &, const Vector &, const Vector &) | |
Creates a circle given three vertices. More... | |
~Circle () | |
Empty. | |
bool | Intersect (const Ray &, double &) const |
Compute the ray-disc intersection. More... | |
Vector | Center () const |
Gets the center of a circle. | |
Vector | Axis () const |
Axis of the circle. | |
double | Radius () const |
Radius of the circle. | |
double | R (const Vector &) const |
Compute the distance between a point and a circle. More... | |
Vector | Normal (const Vector &) const |
Computes the distance vector between a circle and a point. More... | |
void | Rotate (const Matrix &) |
Rotates a circle. More... | |
void | Translate (const Vector &) |
Transltes a circle. More... | |
void | Scale (const double &) |
Uniformly scales a circle. More... | |
Box | GetBox () const |
Compute the axis aligned bounding box of a circle. More... | |
double | Area () const |
Area of a circle. More... | |
Vector | RandomInside (Random &=Random::R239) const |
Generate a random vector inside the circle. More... | |
Vector | RandomOn (Random &=Random::R239) const |
Generate a random vector on the circle. More... | |
Static Public Member Functions | |
static double | Area (const double &) |
Area of a circle given its radius. More... | |
Protected Attributes | |
Vector | c = Vector::Null |
Center of the circle. | |
Vector | axis = Vector::Z |
Axis. | |
double | r = 1.0 |
Radius. | |
Static Protected Attributes | |
static constexpr const double | epsilon = 1.0e-10 |
Internal epsilon constant. | |
Friends | |
std::ostream & | operator<< (std::ostream &, const Circle &) |
Overloaded. More... | |
Circles.
Circles are characterized by their center, axis and radius. They are sometimes interpreted as discs, as for ray intersection.
|
explicit |
Creates a circle.
r | Radius. |
Creates a circle.
c | Center. |
axis | Axis, which should be normalized. |
r | Radius. |
Creates a circle given three vertices.
Basically set the center to the center of the triangle, and compute the radius.
x,y,z | Argument vertices |
|
inline |
Area of a circle.
|
inlinestatic |
Area of a circle given its radius.
This static function avoids the creation of an instance of a circle.
r | Radius. |
Box Circle::GetBox | ( | ) | const |
Compute the axis aligned bounding box of a circle.
Some math will demonstrate that the box can be computed easily directly from the axis of the circle. Computations involve three square roots. For a larger but even faster bounding box, use the bounding box of the corresponding sphere:
bool Circle::Intersect | ( | const Ray & | ray, |
double & | t | ||
) | const |
Compute the ray-disc intersection.
ray | The ray. |
t | Intersection depth. |
Computes the distance vector between a circle and a point.
This function projects the point in the plane of the circle and computes the distance to the circle in its plane, before adding the extra term along the normal.
p | Point. |
double Circle::R | ( | const Vector & | p | ) | const |
Compute the distance between a point and a circle.
Cost: 10+, 8*, 1sqrt
p | Point. |
Vector Circle::RandomInside | ( | Random & | random = Random::R239 | ) | const |
Generate a random vector inside the circle.
random | Random number generator. |
Vector Circle::RandomOn | ( | Random & | random = Random::R239 | ) | const |
Generate a random vector on the circle.
random | Random number generator. |
void Circle::Rotate | ( | const Matrix & | r | ) |
Rotates a circle.
r | Rotation matrix. |
void Circle::Scale | ( | const double & | s | ) |
Uniformly scales a circle.
s | Scaling factor. |
void Circle::Translate | ( | const Vector & | t | ) |
Transltes a circle.
t | Translation vector. |
|
friend |
Overloaded.
s | Stream. |
circle | The circle. |