Raytracer
Loading...
Searching...
No Matches
Sphere.hpp
1#include <memory>
2#include "interfaces/IHittable.hpp"
3#include "utils/VecN.hpp"
4
5#ifndef __SPHERE_HPP__
6 #define __SPHERE_HPP__
7
8namespace Raytracer::Shapes
9{
11 private:
12 Utils::Point3 _center;
13 double _radius;
14 std::shared_ptr<Interfaces::IMaterial> _material;
15 bool _isMoving = false;
16 Utils::Vec3 _centerVec;
18
19 public:
20 Sphere(const Utils::Point3 &center, double radius,
21 std::shared_ptr<Interfaces::IMaterial> material);
22 Sphere(const Utils::Point3 &centerOne, const Utils::Point3 &centerTwo,
23 double radius, std::shared_ptr<Interfaces::IMaterial> material);
24 bool hit(const Core::Ray &ray, Utils::Interval interval,
25 Core::Payload &hit) const override;
26 Utils::Point3 sphereCenter(double time) const;
27 Utils::AxisAlignedBBox boundingBox() const override;
28 static void getSphereUV(
29 const Utils::Point3 &point, double &u, double &v);
30 };
31} // namespace Raytracer::Shapes
32
33#endif /* __SPHERE_HPP__ */
Definition Payload.hpp:11
Definition Ray.hpp:9
Definition IHittable.hpp:11
Definition Sphere.hpp:10
Utils::AxisAlignedBBox boundingBox() const override
Get the bounding box of the sphere.
Definition Sphere.cpp:111
static void getSphereUV(const Utils::Point3 &point, double &u, double &v)
Get the UV coordinates of the sphere.
Definition Sphere.cpp:140
Utils::Point3 sphereCenter(double time) const
Get the center of the sphere at the given time.
Definition Sphere.cpp:125
Sphere(const Utils::Point3 &center, double radius, std::shared_ptr< Interfaces::IMaterial > material)
Construct a new Sphere object.
Definition Sphere.cpp:17
bool hit(const Core::Ray &ray, Utils::Interval interval, Core::Payload &hit) const override
Check if the ray hits the sphere.
Definition Sphere.cpp:67
Definition AxisAlignedBBox.hpp:10
Definition Interval.hpp:9
Definition VecN.hpp:40