ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
shapes/include/shapes/SpheroCylinder.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010
4 * Max-Planck-Institute for Polymer Research, Theory Group
5 *
6 * This file is part of ESPResSo.
7 *
8 * ESPResSo is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * ESPResSo is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef SRC_SHAPES_SPHEROCYLINDER_HPP
23#define SRC_SHAPES_SPHEROCYLINDER_HPP
24
25#include "Shape.hpp"
26#include <utils/Vector.hpp>
27
28namespace Shapes {
29class SpheroCylinder : public Shape {
30public:
31 /** center of the cylinder. */
33 /** Axis of the cylinder. */
35 /** cylinder radius. */
36 double m_rad;
37 /** cylinder length. */
38 double m_length;
39
40 /** Center of smoothing circle */
42 /** direction -1: inside, +1 outside */
44 /** Unit vector in z direction */
46
47 /** Alternative e_r for corner case */
49
50 /** @brief Calculate derived parameters. */
51 void precalc() {
52 m_half_length = 0.5 * m_length;
53
54 e_z = m_axis / m_axis.norm();
55
56 /* Find a vector orthogonal to e_z, since {1,0,0} and
57 {0,1,0} are independent, e_z can not be parallel to both
58 of them. Then we can do Gram-Schmidt */
59 if ((Utils::Vector3d{1., 0., 0} * e_z) < 1.)
60 e_r_axis =
61 Utils::Vector3d{1., 0., 0} - (e_z * Utils::Vector3d{1., 0., 0}) * e_z;
62 else
63 e_r_axis =
64 Utils::Vector3d{0., 1., 0} - (e_z * Utils::Vector3d{0., 1., 0}) * e_z;
65
67 }
68
69public:
71 : m_center({0.0, 0.0, 0.0}), m_axis({1.0, 0.0, 0.0}), m_rad(0),
72 m_length(0.0) {
73 precalc();
74 }
75
76 double radius() const { return m_rad; }
77 void set_radius(double const &radius) {
78 m_rad = radius;
79 precalc();
80 }
81
82 double length() const { return m_length; }
83 void set_length(double const &length) {
85 precalc();
86 }
87
88 Utils::Vector3d const &axis() const { return m_axis; }
90 m_axis = axis;
91 precalc();
92 }
93
95 double &direction() { return m_direction; }
96
97 void calculate_dist(const Utils::Vector3d &pos, double &dist,
98 Utils::Vector3d &vec) const override;
99};
100} // namespace Shapes
101
102#endif
Vector implementation and trait types for boost qvm interoperability.
__shared__ int pos[MAXDEPTH *THREADS5/WARPSIZE]
Utils::Vector3d e_r_axis
Alternative e_r for corner case.
Utils::Vector3d m_axis
Axis of the cylinder.
void precalc()
Calculate derived parameters.
double m_half_length
Center of smoothing circle.
Utils::Vector3d m_center
center of the cylinder.
void calculate_dist(const Utils::Vector3d &pos, double &dist, Utils::Vector3d &vec) const override
void set_axis(Utils::Vector3d const &axis)
double m_direction
direction -1: inside, +1 outside
Utils::Vector3d e_z
Unit vector in z direction.
Vector & normalize()
Definition Vector.hpp:140
T norm() const
Definition Vector.hpp:131