FancySpheres Class Reference

Public Member Functions

EIGEN_MAKE_ALIGNED_OPERATOR_NEW FancySpheres ()
 
void draw ()
 

Protected Attributes

std::vector< Vector3f > mCenters
 
std::vector< float > mRadii
 
IcoSphere mIcoSphere
 

Constructor & Destructor Documentation

◆ FancySpheres()

EIGEN_MAKE_ALIGNED_OPERATOR_NEW FancySpheres::FancySpheres ( )
inline
34  {
35  const int levels = 4;
36  const float scale = 0.33;
37  float radius = 100;
38  std::vector<int> parents;
39 
40  // leval 0
41  mCenters.push_back(Vector3f::Zero());
42  parents.push_back(-1);
43  mRadii.push_back(radius);
44 
45  // generate level 1 using icosphere vertices
46  radius *= 0.45;
47  {
48  float dist = mRadii[0] * 0.9;
49  for (int i = 0; i < 12; ++i) {
50  mCenters.push_back(mIcoSphere.vertices()[i] * dist);
51  mRadii.push_back(radius);
52  parents.push_back(0);
53  }
54  }
55 
56  static const float angles[10] = {0, 0, M_PI, 0. * M_PI, M_PI, 0.5 * M_PI, M_PI, 1. * M_PI, M_PI, 1.5 * M_PI};
57 
58  // generate other levels
59  int start = 1;
60  for (int l = 1; l < levels; l++) {
61  radius *= scale;
62  int end = mCenters.size();
63  for (int i = start; i < end; ++i) {
64  Vector3f c = mCenters[i];
65  Vector3f ax0 = (c - mCenters[parents[i]]).normalized();
66  Vector3f ax1 = ax0.unitOrthogonal();
67  Quaternionf q;
68  q.setFromTwoVectors(Vector3f::UnitZ(), ax0);
70  for (int j = 0; j < 5; ++j) {
71  Vector3f newC =
72  c + ((AngleAxisf(angles[j * 2 + 1], ax0) * AngleAxisf(angles[j * 2 + 0] * (l == 1 ? 0.35 : 0.5), ax1)) *
73  ax0) *
74  (mRadii[i] + radius * 0.8);
75  mCenters.push_back(newC);
76  mRadii.push_back(radius);
77  parents.push_back(i);
78  }
79  }
80  start = end;
81  }
82  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
std::vector< float > mRadii
Definition: quaternion_demo.cpp:99
std::vector< Vector3f > mCenters
Definition: quaternion_demo.cpp:98
IcoSphere mIcoSphere
Definition: quaternion_demo.cpp:100
const std::vector< Eigen::Vector3f > & vertices() const
Definition: icosphere.h:19
static constexpr lastp1_t end
Definition: IndexedViewHelper.h:79
Transform< float, 3, Affine > Affine3f
Definition: Transform.h:682
AngleAxis< float > AngleAxisf
Definition: AngleAxis.h:165
#define M_PI
Definition: main.h:121
EIGEN_DEVICE_FUNC const Scalar & q
Definition: SpecialFunctionsImpl.h:2019
UniformScaling< float > Scaling(float s)
Definition: Eigen/src/Geometry/Scaling.h:138
Translation< float, 3 > Translation3f
Definition: Translation.h:174
radius
Definition: UniformPSDSelfTest.py:15
int c
Definition: calibrate.py:100
void start(const unsigned &i)
(Re-)start i-th timer
Definition: oomph_utilities.cc:243
double Zero
Definition: pseudosolid_node_update_elements.cc:35
t
Definition: plotPSD.py:36
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References calibrate::c, Eigen::placeholders::end, i, j, M_PI, Eigen::numext::q, UniformPSDSelfTest::radius, Eigen::Scaling(), oomph::CumulativeTimings::start(), plotPSD::t, and oomph::PseudoSolidHelper::Zero.

Member Function Documentation

◆ draw()

void FancySpheres::draw ( )
inline
84  {
85  int end = mCenters.size();
86  glEnable(GL_NORMALIZE);
87  for (int i = 0; i < end; ++i) {
89  gpu.pushMatrix(GL_MODELVIEW);
90  gpu.multMatrix(t.matrix(), GL_MODELVIEW);
91  mIcoSphere.draw(2);
92  gpu.popMatrix(GL_MODELVIEW);
93  }
94  glDisable(GL_NORMALIZE);
95  }
void pushMatrix(const Matrix< Scalar, 4, 4, Flags_, 4, 4 > &mat, GLenum matrixTarget)
Definition: gpuhelper.h:162
void multMatrix(const Matrix< Scalar, 4, 4, Flags_, 4, 4 > &mat, GLenum matrixTarget)
Definition: gpuhelper.h:138
void popMatrix(GLenum matrixTarget)
Definition: gpuhelper.h:174
void draw(int level)
Definition: icosphere.cpp:90
GpuHelper gpu
Definition: gpuhelper.cpp:18

References Eigen::placeholders::end, gpu, i, GpuHelper::multMatrix(), GpuHelper::popMatrix(), GpuHelper::pushMatrix(), Eigen::Scaling(), and plotPSD::t.

Referenced by RenderingWidget::drawScene().

Member Data Documentation

◆ mCenters

std::vector<Vector3f> FancySpheres::mCenters
protected

◆ mIcoSphere

IcoSphere FancySpheres::mIcoSphere
protected

◆ mRadii

std::vector<float> FancySpheres::mRadii
protected

The documentation for this class was generated from the following file: