67 lines
2.0 KiB
C++
67 lines
2.0 KiB
C++
/*!
|
|
* cylinder.h
|
|
*
|
|
* Copyright (c) 2024, NADAL Jean-Baptiste. All rights reserved.
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
* MA 02110-1301 USA
|
|
*
|
|
* @Author: NADAL Jean-Baptiste
|
|
* @Date: 18/03/2024
|
|
*
|
|
*/
|
|
|
|
#ifndef _RAYTRACER_CYLINDER_H
|
|
#define _RAYTRACER_CYLINDER_H
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
#include <cmath>
|
|
|
|
#include "shapes/shape.h"
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
namespace Raytracer
|
|
{
|
|
class Cylinder : public Shape
|
|
{
|
|
public:
|
|
Cylinder(void) = default;
|
|
Intersections local_intersect(const Ray &a_ray) override;
|
|
Tuple local_normal_at(const Tuple &a_local_point) const override;
|
|
|
|
double minimum(void);
|
|
void set_minimum(double a_value);
|
|
|
|
double maximum(void);
|
|
void set_maximum(double a_value);
|
|
|
|
bool closed(void);
|
|
void set_closed(bool a_state);
|
|
|
|
private:
|
|
bool check_cap(const Ray &a_ray, double a_distance_t);
|
|
void intersect_caps(const Ray &a_ray, Intersections &an_xs);
|
|
|
|
private:
|
|
double m_minimum = -std::numeric_limits<double>::infinity();
|
|
double m_maximum = std::numeric_limits<double>::infinity();
|
|
bool m_closed = false;
|
|
};
|
|
}; // namespace Raytracer
|
|
|
|
#endif // _RAYTRACER_CYLINDER_H
|