Debian Codegraph @

avogadro/rendering/arcstrip.cpp

raw
1 /******************************************************************************
2 This source file is part of the Avogadro project.
3 This source code is released under the 3-Clause BSD License, (see "LICENSE").
4 ******************************************************************************/
5
6 #include "arcstrip.h"
7
8 namespace Avogadro::Rendering {
9
10 void ArcStrip::setArc(const Vector3f& origin, const Vector3f& start,
11 const Vector3f& normal, float degreesCCW,
12 float resolutionDeg, float lineWidth)
13 {
14 // Prepare rotation, calculate sizes
15 const auto resolution =
16 static_cast<unsigned int>(std::fabs(std::ceil(degreesCCW / resolutionDeg)));
17 const auto numVerts = static_cast<size_t>(resolution + 1);
18 const float stepAngleRads =
19 (degreesCCW / static_cast<float>(resolution)) * DEG_TO_RAD_F;
20 const Eigen::AngleAxisf rot(stepAngleRads, normal);
21
22 // Generate vertices
23 Core::Array<Vector3f> verts(numVerts);
24 auto vertsInserter(verts.begin());
25 auto vertsEnd(verts.end());
26 Vector3f radial = start;
27 *(vertsInserter++) = origin + radial;
28 while (vertsInserter != vertsEnd)
29 *(vertsInserter++) = origin + (radial = rot * radial);
30
31 clear();
32 addLineStrip(verts, lineWidth);
33 }
34
35 } // End namespace Avogadro::Rendering