RayZaler 0.1
The free opto-mechanical simulation framework
Conic.h
1//
2// Copyright (c) 2024 Gonzalo José Carracedo Carballal
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU Lesser General Public License as
6// published by the Free Software Foundation, either version 3 of the
7// License, or (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful, but
10// WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU Lesser General Public License for more details.
13//
14// You should have received a copy of the GNU Lesser General Public
15// License along with this program. If not, see
16// <http://www.gnu.org/licenses/>
17//
18
19#ifndef _SURFACES_CONIC_H
20#define _SURFACES_CONIC_H
21
22#include <SurfaceShape.h>
23#include <GLHelpers.h>
24
25namespace RZ {
26 class ConicSurface : public SurfaceShape {
27 Real m_radius = 1;
28 Real m_radius2 = 1;
29 Real m_rCurv = 2;
30 Real m_rCurv2 = 2;
31 Real m_rHole = 0;
32 Real m_rHole2 = 0;
33 Real m_K = 0;
34
35 Real m_x0 = 0;
36 Real m_y0 = 0;
37
38 Real m_ux = 1;
39 Real m_uy = 0;
40 Real m_depth = 1;
41
42 bool m_parabola = false;
43 bool m_convex = false;
44
45 std::vector<GLfloat> m_vertices;
46 std::vector<GLfloat> m_holeVertices;
47 std::vector<GLfloat> m_axes;
48
49 std::vector<std::vector<Real>> m_edges;
50
51 void recalcGLConic();
52 void recalcGLParabolic();
53 void recalcGL();
54 void recalcDistribution();
55
56 public:
57 ConicSurface(Real radius, Real RCurv, Real K);
58 virtual ~ConicSurface() = default;
59
60 void setRadius(Real);
61 void setConicConstant(Real);
62 void setCurvatureRadius(Real);
63 void setCenterOffset(Real, Real);
64 void setHoleRadius(Real);
65 void setConvex(bool);
66
67 virtual bool intercept(
68 Vec3 &hit,
69 Vec3 &normal,
70 Real &tIgnore,
71 Vec3 const &origin,
72 Vec3 const &direction) const override;
73
74 virtual Real area() const override;
75 virtual std::string name() const override;
76
77 virtual void generatePoints(
78 const ReferenceFrame *,
79 Real *pointArr,
80 Real *normals,
81 unsigned int N) override;
82
83 virtual std::vector<std::vector<Real>> const &edges() const override;
84 virtual void renderOpenGL() override;
85 };
86}
87
88#endif // _SURFACES_CONIC_H
Definition: Conic.h:26
Definition: ReferenceFrame.h:59
Definition: SurfaceShape.h:31
Definition: Vector.h:66