SFCGAL 2.0.0
SFCGAL::Sphere Class Reference

Represents a sphere in 3D space. More...

#include <Sphere.h>

Public Member Functions

 Sphere (const Kernel::FT &radius=1.0, const Kernel::Point_3 &center=Kernel::Point_3(0, 0, 0), int num_vertical=16, int num_horizontal=32, const Kernel::Vector_3 &direction=Kernel::Vector_3(0, 0, 1))
 Constructs a Sphere object.
 
 Sphere (const Sphere &other)=default
 Copy constructor.
 
Sphereoperator= (Sphere other)
 Assignment operator.
 
 ~Sphere ()=default
 Destructor.
 
void setRadius (const Kernel::FT &radius)
 Sets the radius of the sphere.
 
void setCenter (const Kernel::Point_3 &center)
 Sets the center of the sphere.
 
void setNumVertical (int num)
 Sets the number of vertical divisions.
 
void setNumHorizontal (int num)
 Sets the number of horizontal divisions.
 
void setDirection (const Kernel::Vector_3 &direction)
 Sets the direction of the sphere.
 
const Kernel::FT & radius () const
 Gets the radius of the sphere.
 
const Kernel::Point_3 & center () const
 Gets the center of the sphere.
 
int numVertical () const
 Gets the number of vertical divisions.
 
int numHorizontal () const
 Gets the number of horizontal divisions.
 
const Kernel::Vector_3 & direction () const
 Gets the direction of the sphere.
 
CGAL::Polyhedron_3< KernelgeneratePolyhedron ()
 Generates a polyhedron representation of the sphere.
 
std::vector< Kernel::Point_3 > generatePoints ()
 Generates a point cloud representation of the sphere.
 
double volume () const
 Calculates the volume of the Sphere.
 
double area () const
 Calculates the surface area of the Sphere.
 

Detailed Description

Represents a sphere in 3D space.

This class provides methods to generate a polyhedron and a point cloud representation of a sphere. It uses SFCGAL's Kernel for exact computations.

Constructor & Destructor Documentation

◆ Sphere() [1/2]

SFCGAL::Sphere::Sphere ( const Kernel::FT & radius = 1.0,
const Kernel::Point_3 & center = Kernel::Point_3(0, 0, 0),
int num_vertical = 16,
int num_horizontal = 32,
const Kernel::Vector_3 & direction = Kernel::Vector_3(0, 0, 1) )

Constructs a Sphere object.

Parameters
radiusThe radius of the sphere
centerThe center point of the sphere
num_verticalThe number of vertical divisions
num_horizontalThe number of horizontal divisions
directionThe direction vector for sphere orientation

◆ Sphere() [2/2]

SFCGAL::Sphere::Sphere ( const Sphere & other)
default

Copy constructor.

◆ ~Sphere()

SFCGAL::Sphere::~Sphere ( )
default

Destructor.

Member Function Documentation

◆ area()

double SFCGAL::Sphere::area ( ) const
inline

Calculates the surface area of the Sphere.

Returns
The surface area of the sphere

◆ center()

const Kernel::Point_3 & SFCGAL::Sphere::center ( ) const
inline

Gets the center of the sphere.

Returns
The center point

◆ direction()

const Kernel::Vector_3 & SFCGAL::Sphere::direction ( ) const
inline

Gets the direction of the sphere.

Returns
The direction vector

◆ generatePoints()

auto SFCGAL::Sphere::generatePoints ( )

Generates a point cloud representation of the sphere.

Returns
A vector of Point_3 objects representing points on the sphere's surface

◆ generatePolyhedron()

auto SFCGAL::Sphere::generatePolyhedron ( )

Generates a polyhedron representation of the sphere.

Returns
A CGAL::Polyhedron_3 object representing the sphere

◆ numHorizontal()

int SFCGAL::Sphere::numHorizontal ( ) const
inline

Gets the number of horizontal divisions.

Returns
The number of horizontal divisions

◆ numVertical()

int SFCGAL::Sphere::numVertical ( ) const
inline

Gets the number of vertical divisions.

Returns
The number of vertical divisions

◆ operator=()

auto SFCGAL::Sphere::operator= ( Sphere other)

Assignment operator.

◆ radius()

const Kernel::FT & SFCGAL::Sphere::radius ( ) const
inline

Gets the radius of the sphere.

Returns
The radius

◆ setCenter()

void SFCGAL::Sphere::setCenter ( const Kernel::Point_3 & center)
inline

Sets the center of the sphere.

Parameters
centerThe new center point

◆ setDirection()

void SFCGAL::Sphere::setDirection ( const Kernel::Vector_3 & direction)
inline

Sets the direction of the sphere.

Parameters
directionThe new direction vector

◆ setNumHorizontal()

void SFCGAL::Sphere::setNumHorizontal ( int num)
inline

Sets the number of horizontal divisions.

Parameters
numThe new number of horizontal divisions

◆ setNumVertical()

void SFCGAL::Sphere::setNumVertical ( int num)
inline

Sets the number of vertical divisions.

Parameters
numThe new number of vertical divisions

◆ setRadius()

void SFCGAL::Sphere::setRadius ( const Kernel::FT & radius)
inline

Sets the radius of the sphere.

Parameters
radiusThe new radius

◆ volume()

double SFCGAL::Sphere::volume ( ) const
inline

Calculates the volume of the Sphere.

Returns
The volume of the sphere