Core 1.0
|
A cylinder characterized by its end vertices and radius. More...
#include <cylinder.h>
Public Member Functions | |
Cylinder () | |
Empty. | |
Cylinder (const Vector &, const Vector &, const double &) | |
Creates a cylinder. More... | |
Cylinder (const double &, const double &, const double &=1.0) | |
Creates a vertical cylinder. More... | |
Cylinder (const Box &, const Axis &) | |
Creates the boudning cylinder embedding a box rotated around an axis. More... | |
~Cylinder () | |
Empty. | |
double | Radius () const |
Gets the radius of a cylinder. | |
int | Intersect (const Ray &, double &, double &) const |
Compute the intersection between a cylinder and a ray. More... | |
int | Intersect (const Ray &, double &, double &, Vector &, Vector &) const |
Compute the intersections between a cylinder and a ray. More... | |
int | Intersect (const Ray &, double &, Vector &) const |
Compute the first positive intersection between a cylinder and a ray. More... | |
bool | Intersect (const Ray &) const |
Check the intersection between a cylinder and a ray. More... | |
bool | Inside (const Vector &) const |
Check if a point is inside or outside the cylinder. More... | |
double | Volume () const |
Computes the volume of a cylinder. | |
double | Area () const |
Computes the surface area of a cylinder. | |
void | Scale (const double &) |
Uniformly scales a cylinder. More... | |
Cylinder | Transformed (const FrameScaled &) const |
Transformed cylinder. More... | |
Vector | RandomInside (Random &=Random::R239) const |
Generate a random vector inside the cylinder. More... | |
Box | GetBox () const |
Computes the axis-aligned bounding box of a cylinder. More... | |
Cylinder | Rotated (const Matrix &) const |
Return a cylinder rotated by a given matrix. More... | |
Cylinder | Translated (const Vector &) const |
Return a cylinder translated by a given vector. More... | |
Cylinder | Scaled (const double &) const |
Return a scaled cylinder. More... | |
double | R (const Vector &) const |
Squared distance between a point and the cylinder. More... | |
double | R (const Vector &, double &) const |
Computes the squared distance between a point and the cylinder. More... | |
double | Signed (const Vector &) const |
Signed Euclidean distance between a point and a cylinder. More... | |
Vector | Normal (const Vector &) const |
Compute the normal vector to a cylinder skeleton. More... | |
Vector | Vertex (int) const |
Return one of the end vertexes of the axis. | |
Public Member Functions inherited from Axis | |
Axis () | |
Empty. | |
Axis (const Vector &, const Vector &) | |
Creates an axis given end vertices. More... | |
~Axis () | |
Empty. | |
void | Rotate (const Matrix &) |
Rotates an axis. More... | |
void | Translate (const Vector &) |
Translates an axis. More... | |
void | Scale (const double &) |
Uniformly scales an axis. More... | |
void | Scale (const Vector &) |
Scales an axis. More... | |
Quadric | Equation (const Ray &) const |
Compute the polynomial equation of the Euclidean distance between a ray and the axis. More... | |
Vector | Vertex (int) const |
Return one of the end vertexes of the axis. | |
Vector | Point (const double &) const |
Compute a point on the axis. | |
Vector | GetAxis () const |
Returns the normalized axis vector. | |
double | Length () const |
Return the axis length. | |
Vector | Symmetric (const Vector &) const |
Symmetric point. More... | |
Sphere | Symmetric (const Sphere &) const |
Symmetric sphere. More... | |
Vector | Normal (const Vector &) const |
Compute the normal vector between a point and its projection onto the edge. More... | |
double | R (const Vector &) const |
Compute the squared distance to the segment. More... | |
double | R (const Axis &) const |
Compute the squared distance between two axes. More... | |
double | R (const Vector &, double &) const |
Compute the squared distance to the axis. More... | |
Matrix | GetFrame () const |
Compute an orthonormal frame attached to the axis. More... | |
Static Public Member Functions | |
static int | Cast (const Vector &, double &, double &) |
Computes the inverse mapping of a point. More... | |
Static Public Member Functions inherited from Axis | |
static Matrix | GetFrame (const Vector &) |
Compute an orthonormal frame attached to the axis. More... | |
static Vector | BoxVector (const Vector &) |
Compute the box vector extent of a unit circle with a given axis. More... | |
Static Public Attributes | |
static const double | epsilon = 1.0e-4 |
Epsilon value for intersection tests. | |
static const Cylinder | Unit |
Unit vertical cylinder. | |
Protected Attributes | |
double | r = 1.0 |
Radius. | |
Protected Attributes inherited from Axis | |
Vector | b = Vector::Z |
End vertices of the axis. | |
Vector | axis = Vector::Z |
Normalized axis vector. | |
double | length = 1.0 |
Length of the axis. | |
Friends | |
std::ostream & | operator<< (std::ostream &, const Cylinder &) |
Overloaded. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from Axis | |
double | Radial (const Vector &, Vector &, Vector &) const |
Compute the radial coordinates of a point. More... | |
Vector2 | Radial (const Vector &) const |
Compute the radial coordinates of a point. More... | |
A cylinder characterized by its end vertices and radius.
Note that only the radius is stored, the squared radius value is computed on the fly whenever needed.
Creates a cylinder.
a,b | End vertices of the axis. |
r | Radius of the cylinder. |
|
explicit |
Creates a vertical cylinder.
a,b | Height of apexes. |
r | Radius. |
Creates the boudning cylinder embedding a box rotated around an axis.
box | The box. |
ax | The axis. |
|
static |
Computes the inverse mapping of a point.
Projects the point onto the z-axis unit cylinder, uv-coordinates are set to unit interval [0,1].
p | point |
u,v | inverse mapping coordinates |
Box Cylinder::GetBox | ( | ) | const |
Computes the axis-aligned bounding box of a cylinder.
bool Cylinder::Inside | ( | const Vector & | p | ) | const |
Check if a point is inside or outside the cylinder.
p | Point. |
bool Cylinder::Intersect | ( | const Ray & | ray | ) | const |
Check the intersection between a cylinder and a ray.
ray | The ray. |
int Cylinder::Intersect | ( | const Ray & | ray, |
double & | ta, | ||
double & | tb | ||
) | const |
Compute the intersection between a cylinder and a ray.
Intersections are sorted according to intersection depth.
ray | The ray. |
ta,tb | Intersection depths. |
int Cylinder::Intersect | ( | const Ray & | ray, |
double & | ta, | ||
double & | tb, | ||
Vector & | na, | ||
Vector & | nb | ||
) | const |
Compute the intersections between a cylinder and a ray.
Intersections are sorted according to intersection depth.
ray | The ray. |
ta,tb | Intersection depths. |
na,nb | Normals at intersection points. |
Compute the first positive intersection between a cylinder and a ray.
ray | The ray. |
t | Intersection depth. |
n | Normal at intersection point. |
Compute the normal vector to a cylinder skeleton.
Project the point in space onto the axis of the cylinder. If projection lies inside the segment, then return the normal to the segment minus the right radius direction, otherwise perform computations for the end caps.
p | Point. |
double Cylinder::R | ( | const Vector & | p | ) | const |
Squared distance between a point and the cylinder.
From A. Barbier and E. Galin. Fast distance Computation between a Point and Cylinders, Cones, Line-swept-Spheres and Cone-Spheres. Journal of Graphics Tools, 9(2), 11-19, 2004.
Cost in worst case: 11 +, 9 *, 1 sqrt, 3 if.
p | Point. |
double Cylinder::R | ( | const Vector & | p, |
double & | s | ||
) | const |
Computes the squared distance between a point and the cylinder.
p | Point. |
s | Returned position of the projected point onto the axis of the cylinder. |
Vector Cylinder::RandomInside | ( | Random & | random = Random::R239 | ) | const |
Generate a random vector inside the cylinder.
random | Random number generator. |
Return a cylinder rotated by a given matrix.
r | Rotation matrix. |
void Cylinder::Scale | ( | const double & | s | ) |
Uniformly scales a cylinder.
s | Scaling factor. |
Cylinder Cylinder::Scaled | ( | const double & | s | ) | const |
Return a scaled cylinder.
s | Scaling factor. |
double Cylinder::Signed | ( | const Vector & | p | ) | const |
Signed Euclidean distance between a point and a cylinder.
p | Point. |
Cylinder Cylinder::Transformed | ( | const FrameScaled & | frame | ) | const |
Transformed cylinder.
frame | Frame. |
Return a cylinder translated by a given vector.
t | Translation vector. |
|
friend |
Overloaded.
s | Stream. |
cylinder | The cylinder. |