20 TruncatedEllipsoid::TruncatedEllipsoid(
double r_x,
double r_y,
double r_z,
double height,
double dh)
22 static const int n_heights =
23 std::max(2,
static_cast<int>(std::round(
24 static_cast<double>(IShape::N_Circle) * height / 2.0 / r_z + 0.5)));
25 double h_step = (height - dh) / (n_heights - 1);
26 m_vertices.resize(n_heights * IShape::N_Circle);
28 for (
int i = 0; i < n_heights; ++i) {
29 double z = i * h_step;
30 double radius_factor = std::sqrt(1.0 - std::pow((z + r_z - height) / r_z, 2));
31 auto ellipse =
EllipseVertices(radius_factor * r_x, radius_factor * r_y, i * h_step);
32 std::move(ellipse.begin(), ellipse.end(), it);
33 it = it + ellipse.size();
37 TruncatedEllipsoid::~TruncatedEllipsoid() =
default;
std::vector< kvector_t > EllipseVertices(double r_x, double r_y, double z)
Generate vertices of centered ellipse with given semi-axes at height z.
Defines class TruncatedEllipsoid.
std::vector< kvector_t > m_vertices
List of vertices initialized during construction.