QUGaR 0.1.3
Loading...
Searching...
No Matches
primitive_funcs_lib.hpp
Go to the documentation of this file.
1// --------------------------------------------------------------------------
2//
3// Copyright (C) 2025-present by Pablo Antolin
4//
5// This file is part of the QUGaR library.
6//
7// SPDX-License-Identifier: MIT
8//
9// --------------------------------------------------------------------------
10
11#ifndef QUGAR_IMPL_PRIMITIVE_FUNCS_LIB_HPP
12#define QUGAR_IMPL_PRIMITIVE_FUNCS_LIB_HPP
13
20
21#include <qugar/bezier_tp.hpp>
25#include <qugar/numbers.hpp>
26#include <qugar/point.hpp>
27#include <qugar/ref_system.hpp>
28#include <qugar/types.hpp>
29
30#include <memory>
31
34namespace qugar::impl::funcs {
35
40template<int dim> class SphereBase
41{
42public:
48
51 [[nodiscard]] real radius() const;
52
55 [[nodiscard]] const Point<dim> &center() const;
56
57protected:
60 [[nodiscard]] static Point<dim> get_default_center();
61
64
67};
68
69
79template<int dim>
80class Sphere
81 : public SphereBase<dim>
82 , public ImplicitFunc<dim>
83{
84public:
88 explicit Sphere(real radius);
89
95
97};
98
99
109template<int dim>
111 : public SphereBase<dim>
112 , public BezierTP<dim, 1>
113{
114public:
119
125
126private:
132 [[nodiscard]] static std::shared_ptr<MonomialsTP<dim, 1>> create_monomials(real radius, const Point<dim> &center);
133};
134
143{
144public:
151
152
155 [[nodiscard]] real radius() const;
156
159 [[nodiscard]] const Point<3> &origin() const;
160
163 [[nodiscard]] const Point<3> &axis() const;
164
165protected:
168 [[nodiscard]] static Point<3> get_default_origin();
169
172 [[nodiscard]] static Point<3> get_default_axis();
173
176
179
182};
183
194 : public CylinderBase
195 , public BezierTP<3, 1>
196{
197public:
203
210
217
223 [[nodiscard]] static std::shared_ptr<MonomialsTP<3, 1>>
225};
226
227
238 : public CylinderBase
239 , public ImplicitFunc<3>
240{
241public:
242 static const int dim = 3;
243
249
256
263
265};
266
275template<int dim> class EllipsoidBase
276{
277public:
283
286 [[nodiscard]] const Point<dim> &semi_axes() const;
287
290 [[nodiscard]] const RefSystem<dim> &ref_system() const;
291
292protected:
295
298
301 [[nodiscard]] static RefSystem<dim> get_default_system();
302};
303
313template<int dim>
315 : public EllipsoidBase<dim>
316 , public BezierTP<dim, 1>
317{
318public:
323
329
330private:
335 [[nodiscard]] static std::shared_ptr<MonomialsTP<dim, 1>> create_monomials(const Point<dim> &semi_axes,
336 const RefSystem<dim> &system);
337};
338
348template<int dim>
350 : public EllipsoidBase<dim>
351 , public ImplicitFunc<dim>
352{
353public:
358
364
366};
367
373{
374public:
381
384 [[nodiscard]] const Point<2> &center() const;
385
388 [[nodiscard]] real inner_radius() const;
389
392 [[nodiscard]] real outer_radius() const;
393
394protected:
397
400
403
406 [[nodiscard]] static Point<2> get_default_center();
407};
408
415 : public AnnulusBase
416 , public BezierTP<2, 1>
417{
418public:
426
433
434private:
440 [[nodiscard]] static std::shared_ptr<MonomialsTP<2, 1>>
442};
443
444
472
480{
481public:
489
492 [[nodiscard]] real major_radius() const;
493
496 [[nodiscard]] real minor_radius() const;
497
500 [[nodiscard]] const Point<3> &center() const;
501
504 [[nodiscard]] const Point<3> &axis() const;
505
506protected:
509
512
515
518
521 [[nodiscard]] static Point<3> get_default_center();
522
525 [[nodiscard]] static Point<3> get_default_axis();
526};
527
528
537 : public TorusBase
538 , public BezierTP<3, 1>
539{
540public:
548
557
558
566
567private:
574 [[nodiscard]] static std::shared_ptr<MonomialsTP<3, 1>>
576};
577
630
634{
635public:
636 static constexpr real default_value = numbers::half;
637
642
645 [[nodiscard]] real value() const;
646
647protected:
649 real value_{ 0.0 };
650};
651
655template<int dim>
657 : public ConstantBase
658 , public BezierTP<dim, 1>
659{
660public:
663
668};
669
673template<int dim>
675 : public ConstantBase
676 , public ImplicitFunc<dim>
677{
678public:
681
685 explicit Constant(real value);
686
688};
689
695template<int dim> class PlaneBase
696{
697public:
701
704 [[nodiscard]] const Point<dim> &origin() const;
705
708 [[nodiscard]] const Point<dim> &normal() const;
709
710protected:
713
716
720 [[nodiscard]] static Point<dim> get_default_origin();
721
725 [[nodiscard]] static Point<dim> get_default_normal();
726};
727
734template<int dim>
736 : public PlaneBase<dim>
737 , public BezierTP<dim, 1>
738{
739public:
742
746
747private:
752 [[nodiscard]] static std::shared_ptr<MonomialsTP<dim, 1>> create_monomials(const Point<dim> &origin,
753 const Point<dim> &normal);
754};
755
762template<int dim>
763class Plane
764 : public PlaneBase<dim>
765 , public ImplicitFunc<dim>
766{
767public:
770
774
776};
777
778
779}// namespace qugar::impl::funcs
780
781
782#endif// QUGAR_IMPL_PRIMITIVE_FUNCS_LIB_HPP
Declaration of tensor-product Bezier class.
BezierTP(const TensorSizeTP< dim > &order)
A class representing a reference system in a given dimension.
Definition ref_system.hpp:35
real outer_radius() const
Gets the outer radius of the annulus.
real inner_radius_
Inner radius of the annulus.
Definition primitive_funcs_lib.hpp:396
real outer_radius_
Outer radius of the annulus.
Definition primitive_funcs_lib.hpp:399
static Point< 2 > get_default_center()
Gets the default center of the cylinder. It is set to the center of the Cartesian coordinate system.
const Point< 2 > & center() const
Gets the center of the annulus.
Point< 2 > center_
Center of the annulus.
Definition primitive_funcs_lib.hpp:402
real inner_radius() const
Gets the inner radius of the annulus.
AnnulusBase(real inner_radius, real outer_radius, const Point< 2 > &center)
Constructor.
AnnulusBzr(real inner_radius, real outer_radius, const Point< 2 > &center)
Constructor.
AnnulusBzr(real inner_radius, real outer_radius)
Constructor.
static std::shared_ptr< MonomialsTP< 2, 1 > > create_monomials(real inner_radius, real outer_radius, const Point< 2 > &center)
Creates a polynomial representation based on monomials for the given radii and center.
Annulus(real inner_radius, real outer_radius)
Constructor.
Annulus(real inner_radius, real outer_radius, const Point< 2 > &center)
Constructor.
declare_impl_func_virtual_interface_2D
Definition primitive_funcs_lib.hpp:470
real value_
Constant value.
Definition primitive_funcs_lib.hpp:649
real value() const
Gets the constant value.
static constexpr real default_value
Definition primitive_funcs_lib.hpp:636
ConstantBase(real value)
Constructor.
ConstantBzr()
Default constructor. Sets constant value to 0.5.
ConstantBzr(real value)
Constructor.
Constant()
Default constructor. Sets constant value to 0.5.
declare_impl_func_virtual_interface
Definition primitive_funcs_lib.hpp:687
Constant(real value)
Constructor.
static Point< 3 > get_default_axis()
Gets the default axis of the cylinder. It is set to the z-axis of the Cartesian coordinate system.
const Point< 3 > & axis() const
Gets the axis of the cylinder.
real radius() const
Gets the radius of the cylinder.
CylinderBase(real radius, const Point< 3 > &origin, const Point< 3 > &axis)
Constructor.
Point< 3 > origin_
Origin of the cylinder.
Definition primitive_funcs_lib.hpp:178
const Point< 3 > & origin() const
Gets the origin of the cylinder.
real radius_
Radius of the cylinder.
Definition primitive_funcs_lib.hpp:175
static Point< 3 > get_default_origin()
Gets the default origin of the cylinder. It is set to the origin of the Cartesian coordinate system.
Point< 3 > axis_
Axis of the axis.
Definition primitive_funcs_lib.hpp:181
CylinderBzr(real radius, const Point< 3 > &origin)
Constructor.
static std::shared_ptr< MonomialsTP< 3, 1 > > create_monomials(real radius, const Point< 3 > &origin, const Point< 3 > &axis)
Creates a polynomial representation based on monomials for the given center, radius,...
CylinderBzr(real radius)
Constructor.
CylinderBzr(real radius, const Point< 3 > &origin, const Point< 3 > &axis)
Constructor.
Cylinder(real radius)
Constructor.
static const int dim
Definition primitive_funcs_lib.hpp:242
declare_impl_func_virtual_interface
Definition primitive_funcs_lib.hpp:264
Cylinder(real radius, const Point< 3 > &origin, const Point< 3 > &axis)
Constructor.
Cylinder(real radius, const Point< 3 > &origin)
Constructor.
RefSystem< dim > system_
Ellipsoid's reference system.
Definition primitive_funcs_lib.hpp:297
const Point< dim > & semi_axes() const
Gets the semi-axes of the ellipsoid.
EllipsoidBase(const Point< dim > &semi_axes, const RefSystem< dim > &system)
Constructs an Ellipsoid object with specified semi-axes and reference system.
static RefSystem< dim > get_default_system()
Gets the default reference system of the ellipsoid.
Point< dim > semi_axes_
Ellipsoid's semi-axes.
Definition primitive_funcs_lib.hpp:294
const RefSystem< dim > & ref_system() const
Gets the reference system of the ellipsoid.
EllipsoidBzr(const Point< dim > &semi_axes, const RefSystem< dim > &system)
Constructs an Ellipsoid object with specified semi-axes and reference system.
EllipsoidBzr(const Point< dim > &semi_axes)
Constructor.
static std::shared_ptr< MonomialsTP< dim, 1 > > create_monomials(const Point< dim > &semi_axes, const RefSystem< dim > &system)
Creates a polynomial representation based on monomials for the given semi-axes and reference system.
Ellipsoid(const Point< dim > &semi_axes)
Constructor.
Ellipsoid(const Point< dim > &semi_axes, const RefSystem< dim > &system)
Constructs an Ellipsoid object with specified semi-axes and reference system.
declare_impl_func_virtual_interface
Definition primitive_funcs_lib.hpp:365
static Point< dim > get_default_origin()
Gets the default origin of the plane. It is set to the origin of the Cartesian coordinate system.
Point< dim > origin_
Origin of the (levelset) line.
Definition primitive_funcs_lib.hpp:712
const Point< dim > & normal() const
Gets the normal of the plane.
const Point< dim > & origin() const
Gets the origin of the plane.
static Point< dim > get_default_normal()
Gets the default normal vector of the plane. It is set to the x-axis.
PlaneBase(const Point< dim > &origin, const Point< dim > &normal)
Constructs a new plane function. The line is defined by an origin and a normal vector.
Point< dim > normal_
Normal to the (levelset) line.
Definition primitive_funcs_lib.hpp:715
static std::shared_ptr< MonomialsTP< dim, 1 > > create_monomials(const Point< dim > &origin, const Point< dim > &normal)
Creates a polynomial representation based on monomials for the given origin a normal.
PlaneBzr()
Constructs a new plane function. The line (levelset) is the line x=0.
PlaneBzr(const Point< dim > &origin, const Point< dim > &normal)
Constructs a new plane function. The line is defined by an origin and a normal vector.
Plane(const Point< dim > &origin, const Point< dim > &normal)
Constructs a new plane function. The line is defined by an origin and a normal vector.
declare_impl_func_virtual_interface
Definition primitive_funcs_lib.hpp:775
Plane()
Constructs a new plane function. The line (levelset) is the line x=0.
Point< dim > center_
Center of the sphere.
Definition primitive_funcs_lib.hpp:66
SphereBase(real radius, const Point< dim > &center)
Constructs a Sphere object with a specified center and radius.
real radius() const
Gets the radius of the sphere.
static Point< dim > get_default_center()
Gets the default center of the sphere. It is set to the origin of the Cartesian coordinate system.
real radius_
Radius of the sphere.
Definition primitive_funcs_lib.hpp:63
const Point< dim > & center() const
Gets the center of the sphere.
static std::shared_ptr< MonomialsTP< dim, 1 > > create_monomials(real radius, const Point< dim > &center)
Creates a polynomial representation based on monomials for the given center and radius.
SphereBzr(real radius)
Constructs a Sphere with the given radius and centered at the origin.
SphereBzr(real radius, const Point< dim > &center)
Constructs a Sphere object with a specified center and radius.
declare_impl_func_virtual_interface
Definition primitive_funcs_lib.hpp:96
Sphere(real radius, const Point< dim > &center)
Constructs a Sphere object with a specified center and radius.
Sphere(real radius)
Constructs a Sphere with the given radius and centered at the origin.
real major_radius() const
Gets the major radius of the torus.
const Point< 3 > & center() const
Gets the center of the plane.
TorusBase(real major_radius, real minor_radius, const Point< 3 > &center, const Point< 3 > &axis)
Constructor.
Point< 3 > axis_
Axis of the torus.
Definition primitive_funcs_lib.hpp:517
static Point< 3 > get_default_center()
Gets the default center of the torus. It is set to the center of the Cartesian coordinate system.
real minor_radius() const
Gets the minor radius of the torus.
const Point< 3 > & axis() const
Gets the axis of the plane.
static Point< 3 > get_default_axis()
Gets the default axis of the torus. It is set to the z-axis of the Cartesian coordinate system.
real major_radius_
Major radius of the torus.
Definition primitive_funcs_lib.hpp:508
real minor_radius_
Minor radius of the torus.
Definition primitive_funcs_lib.hpp:511
Point< 3 > center_
Center of the torus.
Definition primitive_funcs_lib.hpp:514
TorusBzr(real major_radius, real minor_radius)
Constructor.
static std::shared_ptr< MonomialsTP< 3, 1 > > create_monomials(real major_radius, real minor_radius, const Point< 3 > &center, const Point< 3 > &axis)
Creates a polynomial representation based on monomials for the given radii, center,...
TorusBzr(real major_radius, real minor_radius, const Point< 3 > &center, const Point< 3 > &axis)
Constructor.
TorusBzr(real major_radius, real minor_radius, const Point< 3 > &center)
Constructor.
Torus(real major_radius, real minor_radius, const Point< 3 > &center, const Point< 3 > &axis)
Constructor.
declare_impl_func_virtual_interface_3D
Definition primitive_funcs_lib.hpp:616
Torus(real major_radius, real minor_radius)
Constructor.
Point< 3, T > compute_P_x_0(const Point< 3, T > &point) const
Computes the normal component of the a vector respect to the origin.
Torus(real major_radius, real minor_radius, const Point< 3 > &center)
Constructor.
Declaration of a few implicit functions template class ready to be consumed by Algoim.
Declaration of macros to ease the definition/implementation of implicit functions.
Declaration of tensor-product monomials class.
Definition impl_funcs_lib.hpp:36
ScalarFunc< dim > ImplicitFunc
Alias for implicit functions.
Definition domain_function.hpp:114
constexpr real half
Real one over two value.
Definition numbers.hpp:40
double real
Definition types.hpp:18
Vector< T, dim > Point
Class representing a dim-dimensional Point.
Definition point.hpp:34
Declaration of constant values.
Definition and implementation of Point class.
Declaration of reference system class.
Declaration of types.