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

Circles. More...

#include <circle.h>

Inheritance diagram for Circle:
CircleArc Disc Torus

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...
 

Detailed Description

Circles.

Circles are characterized by their center, axis and radius. They are sometimes interpreted as discs, as for ray intersection.

See also
Disc

Constructor & Destructor Documentation

◆ Circle() [1/3]

Circle::Circle ( const double &  r)
explicit

Creates a circle.

Parameters
rRadius.

◆ Circle() [2/3]

Circle::Circle ( const Vector c,
const Vector axis,
const double &  r 
)
explicit

Creates a circle.

Parameters
cCenter.
axisAxis, which should be normalized.
rRadius.

◆ Circle() [3/3]

Circle::Circle ( const Vector x,
const Vector y,
const Vector z 
)
explicit

Creates a circle given three vertices.

Basically set the center to the center of the triangle, and compute the radius.

Parameters
x,y,zArgument vertices

Member Function Documentation

◆ Area() [1/2]

double Circle::Area ( ) const
inline

Area of a circle.

See also
Circle::Area(const double&)

◆ Area() [2/2]

double Circle::Area ( const double &  r)
inlinestatic

Area of a circle given its radius.

This static function avoids the creation of an instance of a circle.

See also
Circle::Area()
Parameters
rRadius.

◆ GetBox()

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:

Box b(c.Center(),c.Radius());
An axis aligned box.
Definition: box.h:23
Circles.
Definition: circle.h:12
Vector c
Center of the circle.
Definition: circle.h:14

◆ Intersect()

bool Circle::Intersect ( const Ray ray,
double &  t 
) const

Compute the ray-disc intersection.

Parameters
rayThe ray.
tIntersection depth.

◆ Normal()

Vector Circle::Normal ( const Vector p) const

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.

Parameters
pPoint.

◆ R()

double Circle::R ( const Vector p) const

Compute the distance between a point and a circle.

Cost: 10+, 8*, 1sqrt

Parameters
pPoint.

◆ RandomInside()

Vector Circle::RandomInside ( Random random = Random::R239) const

Generate a random vector inside the circle.

Parameters
randomRandom number generator.

◆ RandomOn()

Vector Circle::RandomOn ( Random random = Random::R239) const

Generate a random vector on the circle.

Parameters
randomRandom number generator.

◆ Rotate()

void Circle::Rotate ( const Matrix r)

Rotates a circle.

Parameters
rRotation matrix.

◆ Scale()

void Circle::Scale ( const double &  s)

Uniformly scales a circle.

Parameters
sScaling factor.

◆ Translate()

void Circle::Translate ( const Vector t)

Transltes a circle.

Parameters
tTranslation vector.

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  s,
const Circle circle 
)
friend

Overloaded.

Parameters
sStream.
circleThe circle.