ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
shapes/include/shapes/Torus.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19#ifndef SRC_SHAPES_TORUS_HPP
20#define SRC_SHAPES_TORUS_HPP
21
22#include "Shape.hpp"
23#include <utils/Vector.hpp>
24
25namespace Shapes {
26class Torus : public Shape {
27public:
28 /** center of the shape. */
30 /** Normal axis of the shape. */
32 /** radius. */
33 double m_rad;
34 /** tube radius. */
35 double m_tube_rad;
36 /** direction -1: inside, +1 outside */
38
39 /** Unit vector in z direction */
41
42 /** @brief Calculate derived parameters. */
43 void precalc() { e_z = m_normal / m_normal.norm(); }
44
45public:
47 : m_center({0.0, 0.0, 0.0}), m_normal({1.0, 0.0, 0.0}), m_rad(0.0),
48 m_tube_rad(0.0), m_direction(1.0) {
49 precalc();
50 }
51
52 double radius() const { return m_rad; }
53 void set_radius(double const &radius) {
54 m_rad = radius;
55 precalc();
56 }
57
58 double tube_radius() const { return m_tube_rad; }
59 void set_tube_radius(double const &tube_rad) {
60 m_tube_rad = tube_rad;
61 precalc();
62 }
63
64 Utils::Vector3d const &normal() const { return m_normal; }
67 precalc();
68 }
69
71 double &direction() { return m_direction; }
72
73 void calculate_dist(const Utils::Vector3d &pos, double &dist,
74 Utils::Vector3d &vec) const override;
75};
76} // namespace Shapes
77#endif
Vector implementation and trait types for boost qvm interoperability.
void set_normal(Utils::Vector3d const &normal)
void set_tube_radius(double const &tube_rad)
Utils::Vector3d e_z
Unit vector in z direction.
Utils::Vector3d m_normal
Normal axis of the shape.
void calculate_dist(const Utils::Vector3d &pos, double &dist, Utils::Vector3d &vec) const override
Definition Torus.cpp:26
Utils::Vector3d const & normal() const
Utils::Vector3d & center()
Utils::Vector3d m_center
center of the shape.
void set_radius(double const &radius)
double m_direction
direction -1: inside, +1 outside
double m_tube_rad
tube radius.
void precalc()
Calculate derived parameters.
T norm() const
Definition Vector.hpp:138