Raytracer
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
Raytracer::Shapes::Sphere Class Reference
Inheritance diagram for Raytracer::Shapes::Sphere:
Raytracer::Interfaces::IHittable

Public Member Functions

 Sphere (const Utils::Point3 &center, double radius, std::shared_ptr< Interfaces::IMaterial > material)
 Construct a new Sphere object.
 
 Sphere (const Utils::Point3 &centerOne, const Utils::Point3 &centerTwo, double radius, std::shared_ptr< Interfaces::IMaterial > material)
 Construct a new Sphere object.
 
bool hit (const Core::Ray &ray, Utils::Interval interval, Core::Payload &hit) const override
 Check if the ray hits the sphere.
 
Utils::Point3 sphereCenter (double time) const
 Get the center of the sphere at the given time.
 
Utils::AxisAlignedBBox boundingBox () const override
 Get the bounding box of the sphere.
 

Static Public Member Functions

static void getSphereUV (const Utils::Point3 &point, double &u, double &v)
 Get the UV coordinates of the sphere.
 

Constructor & Destructor Documentation

◆ Sphere() [1/2]

Raytracer::Shapes::Sphere::Sphere ( const Utils::Point3 & center,
double radius,
std::shared_ptr< Interfaces::IMaterial > material )

Construct a new Sphere object.

This function constructs a new Sphere object with the given center, radius, and material. The sphere is centered at the given center with the given radius and material.

Parameters
centerThe center of the sphere.
radiusThe radius of the sphere.
materialThe material of the sphere.
Returns
A new Sphere object.

◆ Sphere() [2/2]

Raytracer::Shapes::Sphere::Sphere ( const Utils::Point3 & one,
const Utils::Point3 & two,
double radius,
std::shared_ptr< Interfaces::IMaterial > material )

Construct a new Sphere object.

This function constructs a new Sphere object with the given centers, radius, and material. The sphere is centered at the given centers with the given radius and material.

Parameters
oneThe first center of the sphere.
twoThe second center of the sphere.
radiusThe radius of the sphere.
materialThe material of the sphere.
Returns
A new Sphere object.

Member Function Documentation

◆ boundingBox()

Raytracer::Utils::AxisAlignedBBox Raytracer::Shapes::Sphere::boundingBox ( ) const
overridevirtual

Get the bounding box of the sphere.

This function returns the bounding box of the sphere.

Returns
The bounding box of the sphere.

Implements Raytracer::Interfaces::IHittable.

◆ getSphereUV()

void Raytracer::Shapes::Sphere::getSphereUV ( const Utils::Point3 & point,
double & u,
double & v )
static

Get the UV coordinates of the sphere.

This function returns the UV coordinates of the sphere.

Parameters
pointThe point to get the UV coordinates.
uThe U coordinate of the UV coordinates.
vThe V coordinate of the UV coordinates.

◆ hit()

bool Raytracer::Shapes::Sphere::hit ( const Core::Ray & ray,
Utils::Interval interval,
Core::Payload & payload ) const
overridevirtual

Check if the ray hits the sphere.

This function checks if the ray hits the sphere. The function returns true if the ray hits the sphere. The function returns false if the ray does not hit the sphere. The function updates the payload with the hit information.

Parameters
rayThe ray to check for hits.
intervalThe interval to check for hits.
payloadThe payload to update with the hit information.
Returns
true if the ray hits the sphere, false otherwise.

Implements Raytracer::Interfaces::IHittable.

◆ sphereCenter()

Raytracer::Utils::Point3 Raytracer::Shapes::Sphere::sphereCenter ( double time) const

Get the center of the sphere at the given time.

This function returns the center of the sphere at the given time.

Parameters
timeThe time to get the center of the sphere.
Returns
The center of the sphere at the given time.

The documentation for this class was generated from the following files: