raytracer
Parallel Ray Tracer written from scratch (no graphics API).
Loading...
Searching...
No Matches
raytracer::raytracer::Sphere Class Reference

#include <sphere.h>

Inheritance diagram for raytracer::raytracer::Sphere:
Collaboration diagram for raytracer::raytracer::Sphere:

Public Member Functions

 Sphere (std::unique_ptr< const Material > _mat, const common::Vec3 &_center, double _radius)
common::Vec3 get_center () const
double get_radius () const
double ray_intersection (const Ray &r) const override
common::Vec3 get_normal (const common::Vec3 &point) const override
ObjectType get_type () const override
Public Member Functions inherited from raytracer::raytracer::Object
virtual ~Object ()=default
 Object (std::unique_ptr< const Material > _mat)
const Material * get_material () const

Detailed Description

A sphere, defined by its center and radius.

Constructor & Destructor Documentation

◆ Sphere()

raytracer::raytracer::Sphere::Sphere ( std::unique_ptr< const Material > _mat,
const common::Vec3 & _center,
double _radius )

Creates a sphere with the given properties.

Parameters
_matThe material of the sphere, owned by the sphere.
_centerThe position of the center of the sphere.
_radiusThe radius of the sphere.
Here is the call graph for this function:

Member Function Documentation

◆ get_center()

common::Vec3 raytracer::raytracer::Sphere::get_center ( ) const
nodiscard

Getter for the center of the sphere.

Returns
The position of the center of the sphere.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_normal()

common::Vec3 raytracer::raytracer::Sphere::get_normal ( const common::Vec3 & point) const
nodiscardoverridevirtual

Returns the normal to the surface of the object at a given point.

Parameters
pointA point on the surface of the object.
Returns
The normal to the surface at that point.

Implements raytracer::raytracer::Object.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_radius()

double raytracer::raytracer::Sphere::get_radius ( ) const
nodiscard

Getter for the radius of the sphere.

Returns
The radius of the sphere.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_type()

ObjectType raytracer::raytracer::Sphere::get_type ( ) const
inlinenodiscardoverridevirtual

Returns the type of the object, used to identify the concrete class.

Returns
The type of the object.

Implements raytracer::raytracer::Object.

◆ ray_intersection()

double raytracer::raytracer::Sphere::ray_intersection ( const Ray & r) const
nodiscardoverridevirtual

Computes the distance along a ray at which it first hits the object.

Parameters
rThe ray to intersect with the object.
Returns
The value t such that r.origin + r.direction * t is the intersection point, or a negative value if the ray does not hit the object.

Implements raytracer::raytracer::Object.

Here is the call graph for this function:
Here is the caller graph for this function:

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