SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLLens Class Reference

SLLens creates a lens mesh based on SLRevolver. More...

#include <SLLens.h>

Inheritance diagram for SLLens:
[legend]

Public Member Functions

 SLLens (SLAssetManager *assetMgr, double sphere, double cylinder, SLfloat diameter, SLfloat thickness, SLuint stacks=32, SLuint slices=32, SLstring name="lens mesh", SLMaterial *mat=nullptr)
 Create a lens with given sphere, cylinder, diameter and thickness. More...
 
 SLLens (SLAssetManager *assetMgr, SLfloat radiusBot, SLfloat radiusTop, SLfloat diameter, SLfloat thickness, SLuint stacks=32, SLuint slices=32, SLstring name="lens mesh", SLMaterial *mat=nullptr)
 Create a lens with given radius, diameter and thickness. More...
 
- Public Member Functions inherited from SLRevolver
 SLRevolver (SLAssetManager *assetMgr, SLVVec3f revolvePoints, SLVec3f revolveAxis, SLuint slices=36, SLbool smoothFirst=false, SLbool smoothLast=false, SLstring name="revolver mesh", SLMaterial *mat=nullptr)
 ctor for generic revolver mesh More...
 
 SLRevolver (SLAssetManager *assetMgr, SLstring name)
 ctor for derived revolver shapes More...
 
void buildMesh (SLMaterial *mat=nullptr)
 
SLuint stacks ()
 
SLuint slices ()
 
- Public Member Functions inherited from SLMesh
 SLMesh (SLAssetManager *assetMgr, const SLstring &name="Mesh")
 Construct a new SLMesh::SLMesh object. More...
 
 ~SLMesh () override
 The destructor deletes everything by calling deleteData. More...
 
virtual void init (SLNode *node)
 SLMesh::shapeInit sets the transparency flag of the AABB. More...
 
virtual void draw (SLSceneView *sv, SLNode *node, SLuint intances=0)
 
void drawIntoDepthBuffer (SLSceneView *sv, SLNode *node, SLMaterial *depthMat)
 Simplified drawing method for shadow map creation. More...
 
void addStats (SLNodeStats &stats)
 
virtual void buildAABB (SLAABBox &aabb, const SLMat4f &wmNode)
 
void updateAccelStruct ()
 
SLbool hit (SLRay *ray, SLNode *node)
 
virtual void preShade (SLRay *ray)
 
virtual void deleteData ()
 SLMesh::deleteData deletes all mesh data and vbo's. More...
 
virtual void deleteDataGpu ()
 
void deleteSelected (SLNode *node)
 Deletes the rectangle selected vertices and the dependent triangles. More...
 
void deleteUnused ()
 Deletes unused vertices (= vertices that are not indexed in I16 or I32) More...
 
virtual void calcMinMax ()
 
virtual void calcNormals ()
 SLMesh::calcNormals recalculates vertex normals for triangle meshes. More...
 
void calcCenterRad (SLVec3f &center, SLfloat &radius)
 
SLbool hitTriangleOS (SLRay *ray, SLNode *node, SLuint iT)
 
virtual void generateVAO (SLGLVertexArray &vao)
 Generate the Vertex Array Object for a specific shader program. More...
 
void computeHardEdgesIndices (float angleRAD, float epsilon)
 computes the hard edges and stores the vertex indexes separately More...
 
void transformSkin (bool forceCPUSkinning, const std::function< void(SLMesh *)> &cbInformNodes)
 Transforms the vertex positions and normals with by joint weights. More...
 
void deselectPartialSelection ()
 
SLMaterialmat () const
 
SLMaterialmatOut () const
 
SLGLPrimitiveType primitive () const
 
const SLAnimSkeletonskeleton () const
 
SLuint numI () const
 
SLGLVertexArrayvao ()
 
SLbool isSelected () const
 
SLfloat edgeAngleDEG () const
 
SLfloat edgeWidth () const
 
SLCol4f edgeColor () const
 
SLVec3f finalP (SLuint i)
 
SLVec3f finalN (SLuint i)
 
SLbool accelStructIsOutOfDate ()
 
void mat (SLMaterial *m)
 
void matOut (SLMaterial *m)
 
void primitive (SLGLPrimitiveType pt)
 
void skeleton (SLAnimSkeleton *skel)
 
void isSelected (bool isSelected)
 
void edgeWidth (SLfloat ew)
 
void edgeAngleDEG (SLfloat ea)
 
void edgeColor (const SLCol4f &ec)
 
void vertexPosEpsilon (SLfloat eps)
 
- Public Member Functions inherited from SLObject
 SLObject (const SLstring &Name="", const SLstring &url="")
 
virtual ~SLObject ()
 
void name (const SLstring &Name)
 
void url (const SLstring &url)
 
const SLstringname () const
 
const SLstringurl () const
 

Private Member Functions

void initLens (SLfloat diopterBot, SLfloat diopterTop, SLfloat diameter, SLfloat thickness, SLuint stacks, SLuint slices, SLMaterial *mat)
 Initialize the lens. More...
 
void generateLens (SLfloat radiusBot, SLfloat radiusTop, SLMaterial *mat)
 Generate the lens with given front and back radius. More...
 
SLfloat generateLensBot (SLfloat radius)
 Generate the bottom (front) part of the lens. More...
 
SLfloat generateLensTop (SLfloat radius)
 Generate the top (back) part of the lens. More...
 
SLfloat calcSagitta (SLfloat radius)
 Calculate the sagitta (s) for a given radius (r) and diameter (l+l) where l is half of the lens diameter See also: http://en.wikipedia.org/wiki/Sagitta_%28geometry%29. More...
 

Private Attributes

SLfloat _diameter
 The diameter of the lens. More...
 
SLfloat _thickness
 The space between the primary planes of lens sides. More...
 
SLfloat _radiusBot
 The radius of the bot (front) side of the lens. More...
 
SLfloat _radiusTop
 The radius of the top (back) side of the lens. More...
 
SLbool _pointOutput
 debug helper More...
 

Additional Inherited Members

- Static Public Member Functions inherited from SLMesh
static void calcTex3DMatrix (SLNode *node)
 
- Public Attributes inherited from SLMesh
SLVVec3f P
 Vector for vertex positions layout (location = 0) More...
 
SLVVec3f N
 Vector for vertex normals (opt.) layout (location = 1) More...
 
SLVVec2f UV [2]
 Array of 2 Vectors for tex. coords. (opt.) layout (location = 2) More...
 
SLVCol4f C
 Vector of vertex colors (opt.) layout (location = 4) More...
 
SLVVec4f T
 Vector of vertex tangents (opt.) layout (location = 5) More...
 
SLVVuchar Ji
 2D Vector of per vertex joint ids (opt.) layout (location = 6) More...
 
SLVVfloat Jw
 2D Vector of per vertex joint weights (opt.) layout (location = 7) More...
 
SLVVec3f skinnedP
 temp. vector for CPU skinned vertex positions More...
 
SLVVec3f skinnedN
 temp. vector for CPU skinned vertex normals More...
 
SLVushort I16
 Vector of vertex indices 16 bit. More...
 
SLVuint I32
 Vector of vertex indices 32 bit. More...
 
SLVuint IS32
 Vector of rectangle selected vertex indices 32 bit. More...
 
SLVushort IE16
 Vector of hard edges vertex indices 16 bit (see computeHardEdgesIndices) More...
 
SLVuint IE32
 Vector of hard edges vertex indices 32 bit (see computeHardEdgesIndices) More...
 
SLVec3f minP
 min. vertex in OS More...
 
SLVec3f maxP
 max. vertex in OS More...
 
- Protected Attributes inherited from SLRevolver
SLVVec3f _revPoints
 Array revolving points. More...
 
SLVec3f _revAxis
 axis of revolution More...
 
SLuint _stacks
 No. of stacks (mostly used) More...
 
SLuint _slices
 NO. of slices. More...
 
SLbool _smoothFirst
 flag if the normal of the first point is eqaual to -revAxis More...
 
SLbool _smoothLast
 flag if the normal of the last point is eqaual to revAxis More...
 
- Protected Attributes inherited from SLMesh
SLGLPrimitiveType _primitive
 Primitive type (default triangles) More...
 
SLMaterial_mat
 Pointer to the inside material. More...
 
SLMaterial_matOut
 Pointer to the outside material. More...
 
SLGLVertexArray _vao
 Main OpenGL Vertex Array Object for drawing. More...
 
SLGLVertexArrayExt _vaoN
 OpenGL VAO for optional normal drawing. More...
 
SLGLVertexArrayExt _vaoT
 OpenGL VAO for optional tangent drawing. More...
 
SLGLVertexArrayExt _vaoS
 OpenGL VAO for optional selection drawing. More...
 
SLbool _isSelected
 Flag if mesh is partially of fully selected. More...
 
SLfloat _edgeAngleDEG
 Edge crease angle in degrees between face normals (30 deg. default) More...
 
SLfloat _edgeWidth
 Line width for hard edge drawing. More...
 
SLCol4f _edgeColor
 Color for hard edge drawing. More...
 
SLfloat _vertexPosEpsilon
 Vertex position epsilon used in computeHardEdgesIndices. More...
 
SLbool _isVolume
 Flag for RT if mesh is a closed volume. More...
 
SLAccelStruct_accelStruct
 KD-tree or uniform grid. More...
 
SLbool _accelStructIsOutOfDate
 Flag if accel. struct needs update. More...
 
SLAnimSkeleton_skeleton
 The skeleton this mesh is bound to. More...
 
SLVMat4f _jointMatrices
 Joint matrix vector for this mesh. More...
 
SLbool _isCPUSkinned
 Flag if mesh has been skinned on CPU during update. More...
 
SLVVec3f_finalP
 Pointer to final vertex position vector. More...
 
SLVVec3f_finalN
 pointer to final vertex normal vector More...
 
- Protected Attributes inherited from SLObject
SLstring _name
 name of an object More...
 
SLstring _url
 uniform resource locator More...
 

Detailed Description

SLLens creates a lens mesh based on SLRevolver.

SLLens creates a lens mesh based on SLRevolver. Different constructors allow to either create the lens from the values written in the eyeglass prescription card or from the radius of the lens.

Lens types:

Myopia ( http://en.wikipedia.org/wiki/Myopia )
The eye is too long for its optical power.
To correct myopic (short-sightedness) a diverging lens is needed.

Hypermetropia ( http://en.wikipedia.org/wiki/Hyperopia )
The eye is too short for its optical power.
To correct presbyopic (far-sightedness) a converging lens is needed.

Definition at line 31 of file SLLens.h.

Constructor & Destructor Documentation

◆ SLLens() [1/2]

SLLens::SLLens ( SLAssetManager assetMgr,
double  sphere,
double  cylinder,
SLfloat  diameter,
SLfloat  thickness,
SLuint  stacks = 32,
SLuint  slices = 32,
SLstring  name = "lens mesh",
SLMaterial mat = nullptr 
)

Create a lens with given sphere, cylinder, diameter and thickness.

SLLens::SLLens ctor for lens revolution object around the y-axis.
Create the lens with the eye prescription card.

The first values in the prescription card is called Sphere. It is also the diopter of the front side of the lens.
The second value from the prescription card is called Cylinder. The sum from the sphere and the cylinder is the diopter of the back side of the lens.
The diopter is the inverse of the focal distance (f) of the lens.
To correct myopic, negative diopters are used.
To correct presbyopic, positive diopters are used.

Parameters
assetMgrPointer to the asset manager
sphereSLfloat taken from the eyeglass passport.
cylinderSLfloat taken from the eyeglass passport.
diameterSLfloat The diameter (h) of the lens
thicknessSLfloat The space between the primary planes of lens sides (d)
stacksSLint
slicesSLint
nameSLstring of the SLRevolver Mesh
matSLMaterial* The Material of the lens

The diopter of the front side is equal to the sphere.
The diopter of the backside is the sum of the spehere and the cylinder.
From the diopter, the radius (R1, R2) can be calculated:
radiusFront = (LensMaterial - OutsideMaterial) / FrontDiopter) * diameter;
radiusBack = (OutsideMaterial - LensMaterial) / BackDiopter) * diameter;

Definition at line 45 of file SLLens.cpp.

53  : SLRevolver(assetMgr, name)
54 {
55  assert(slices >= 3 && "Error: Not enough slices.");
56  assert(slices > 0 && "Error: Not enough stacks.");
57 
58  SLfloat diopterBot = (SLfloat)sphere; // D1 = sphere
59  SLfloat diopterTop = (SLfloat)(sphere + cylinder); // D2 = sphere + cylinder
60 
61  initLens(diopterBot, diopterTop, diameter, thickness, stacks, slices, mat);
62 }
float SLfloat
Definition: SL.h:173
void initLens(SLfloat diopterBot, SLfloat diopterTop, SLfloat diameter, SLfloat thickness, SLuint stacks, SLuint slices, SLMaterial *mat)
Initialize the lens.
Definition: SLLens.cpp:114
SLMaterial * mat() const
Definition: SLMesh.h:177
const SLstring & name() const
Definition: SLObject.h:38
SLuint stacks()
Definition: SLRevolver.h:54
SLuint slices()
Definition: SLRevolver.h:55
SLRevolver(SLAssetManager *assetMgr, SLVVec3f revolvePoints, SLVec3f revolveAxis, SLuint slices=36, SLbool smoothFirst=false, SLbool smoothLast=false, SLstring name="revolver mesh", SLMaterial *mat=nullptr)
ctor for generic revolver mesh
Definition: SLRevolver.cpp:16

◆ SLLens() [2/2]

SLLens::SLLens ( SLAssetManager assetMgr,
SLfloat  radiusBot,
SLfloat  radiusTop,
SLfloat  diameter,
SLfloat  thickness,
SLuint  stacks = 32,
SLuint  slices = 32,
SLstring  name = "lens mesh",
SLMaterial mat = nullptr 
)

Create a lens with given radius, diameter and thickness.

SLLens::SLLens ctor for lens revolution object around the y-axis.
Create the lens with radius.
To correct presbyopic (far-sightedness) a converging lens is needed. To correct myopic (short-sightedness) a diverging lens is needed.

Parameters
assetMgrPointer to the asset manager
radiusBotThe radius of the front side of the lens
radiusTopThe radius of the back side of the lens
diameterThe diameter (h) of the lens
thicknessThe space between the primary planes of lens sides (d)
stacksNo. of stacks of the lens
slicesNo. of slices in the lens
nameName of the SLRevolver Mesh
matPointer to the Material of the lens

Positive radius creates a convex lens side.
Negative radius creates a concave lens side.
Setting the radius to 0 creates a plane.
Combine the two radius to get the required lens.

Definition at line 86 of file SLLens.cpp.

94  : SLRevolver(assetMgr, std::move(name))
95 {
96  SLfloat nOut = 1.00; // kn material outside lens
97  SLfloat nLens = mat->kn(); // kn material of the lens
98  SLfloat diopterBot = (SLfloat)((nLens - nOut) * diameter / radiusBot);
99  SLfloat diopterTop = (SLfloat)((nOut - nLens) * diameter / radiusTop);
100 
101  initLens(diopterBot, diopterTop, diameter, thickness, stacks, slices, mat);
102 }
void kn(SLfloat kn)
Definition: SLMaterial.h:199

Member Function Documentation

◆ calcSagitta()

SLfloat SLLens::calcSagitta ( SLfloat  radius)
private

Calculate the sagitta (s) for a given radius (r) and diameter (l+l) where l is half of the lens diameter See also: http://en.wikipedia.org/wiki/Sagitta_%28geometry%29.

Parameters
radiusr of the lens
Returns
sagitta s of the lens

Definition at line 374 of file SLLens.cpp.

375 {
376  // take the amount of the radius
377  SLfloat radiusAmount = (radius < 0) ? -radius : radius;
378  SLfloat l = _diameter * 0.5f;
379 
380  // sagitta = radius - sqrt( radius*radius - l*l )
381  // calc this part to sort out negative numbers in square root
382  SLfloat part = radiusAmount * radiusAmount - l * l;
383 
384  // set sagitta negative if no bulge is given -> plane
385  SLfloat sagitta = (part >= 0) ? (radiusAmount - sqrt(part)) : -1;
386  return sagitta;
387 }
SLfloat _diameter
The diameter of the lens.
Definition: SLLens.h:71

◆ generateLens()

void SLLens::generateLens ( SLfloat  radiusBot,
SLfloat  radiusTop,
SLMaterial mat 
)
private

Generate the lens with given front and back radius.

Parameters
radiusBotradius of the lens front side
radiusTopradius of the lens back side
matthe material pointer that is passed to SLRevolver

Definition at line 155 of file SLLens.cpp.

158 {
159  _smoothFirst = true;
160  _smoothLast = true;
161  _revAxis.set(0, 1, 0);
162 
163  if (_diameter > 0)
164  {
165  SLfloat x = generateLensTop(radiusTop);
166  if (x < 0.0001f)
167  buildMesh(mat);
168  else
169  cout << "error in lens calculation: (x = " << x << ")" << endl;
170  }
171  else
172  cout << "invalid lens diameter: " << _diameter << endl;
173 }
SLfloat generateLensTop(SLfloat radius)
Generate the top (back) part of the lens.
Definition: SLLens.cpp:272
SLbool _smoothLast
flag if the normal of the last point is eqaual to revAxis
Definition: SLRevolver.h:67
SLVec3f _revAxis
axis of revolution
Definition: SLRevolver.h:59
SLbool _smoothFirst
flag if the normal of the first point is eqaual to -revAxis
Definition: SLRevolver.h:64
void buildMesh(SLMaterial *mat=nullptr)
Definition: SLRevolver.cpp:43
void set(const T X, const T Y, const T Z)
Definition: SLVec3.h:59

◆ generateLensBot()

SLfloat SLLens::generateLensBot ( SLfloat  radius)
private

Generate the bottom (front) part of the lens.

Parameters
radiusof the lens
Returns
x the x coordinate of the last point of the bulge

Definition at line 180 of file SLLens.cpp.

181 {
182  // Point
183  SLVec3f p;
184  SLfloat y;
185  SLfloat x = 0;
186 
187  SLfloat sagitta = calcSagitta(radius);
188  SLint halfStacks = _stacks / 2;
189 
190  // check if lens has a deep
191  if ((sagitta >= 0))
192  {
193  SLfloat alphaAsin = _diameter / (2.0f * radius);
194  alphaAsin = Utils::clamp(alphaAsin, -1.0f, 1.0f);
195  SLfloat alphaRAD = 2.0f * (SLfloat)asin(alphaAsin);
196  SLfloat dAlphaRAD = (alphaRAD * 0.5f) / halfStacks;
197  SLfloat yStart1 = -sagitta;
198  SLfloat currentAlphaRAD = -Utils::HALFPI;
199  SLfloat currentAlphaDEG = currentAlphaRAD * Utils::RAD2DEG;
200  SLfloat radiusAmount1 = radius;
201  SLfloat yTranslate1 = radius - sagitta;
202 
203  // settings for negative radius
204  if (radius < 0)
205  {
206  yStart1 = 0;
207  currentAlphaRAD = Utils::HALFPI;
208  radiusAmount1 = -radius;
209  yTranslate1 = radius;
210  }
211 
212  y = yStart1;
213  // set start point
214  p.x = (SLfloat)x;
215  p.y = (SLfloat)y;
216  p.z = 0;
217  _revPoints.push_back(p);
218  if (_pointOutput) cout << currentAlphaDEG << " x: " << x << " y: " << y << endl;
219 
220  // draw bottom part of the lens
221  for (int i = 0; i < halfStacks; i++)
222  {
223  // change angle
224  currentAlphaRAD += dAlphaRAD;
225  currentAlphaDEG = currentAlphaRAD * Utils::RAD2DEG;
226 
227  // calc x
228  x = cos(currentAlphaRAD) * radiusAmount1;
229 
230  // calc y
231  if ((i + 1 == halfStacks) && (radius >= 0))
232  y = 0;
233  else
234  y = ((sin(currentAlphaRAD)) * radiusAmount1 + yTranslate1);
235 
236  if (_pointOutput) cout << currentAlphaDEG << " x: " << x << " y: " << y << endl;
237 
238  // set point
239  p.x = x;
240  p.y = y;
241  p.z = 0;
242  _revPoints.push_back(p);
243  }
244  }
245  else
246  {
247  SLfloat cutX = (_diameter / 2) / halfStacks;
248 
249  // Draw plane
250  for (int i = 0; i <= halfStacks - 1; i++)
251  {
252  x = cutX * i;
253  y = 0;
254 
255  // set point
256  p.x = x;
257  p.y = y;
258  p.z = 0;
259  _revPoints.push_back(p);
260  if (_pointOutput) cout << "0"
261  << " x: " << x << " y: " << y << " _B" << endl;
262  }
263  }
264  return x;
265 }
int SLint
Definition: SL.h:170
SLfloat calcSagitta(SLfloat radius)
Calculate the sagitta (s) for a given radius (r) and diameter (l+l) where l is half of the lens diame...
Definition: SLLens.cpp:374
SLbool _pointOutput
debug helper
Definition: SLLens.h:75
SLVVec3f _revPoints
Array revolving points.
Definition: SLRevolver.h:58
SLuint _stacks
No. of stacks (mostly used)
Definition: SLRevolver.h:60
T y
Definition: SLVec3.h:43
T x
Definition: SLVec3.h:43
T z
Definition: SLVec3.h:43
static const float HALFPI
Definition: Utils.h:242
T clamp(T a, T min, T max)
Definition: Utils.h:253
static const float RAD2DEG
Definition: Utils.h:238

◆ generateLensTop()

SLfloat SLLens::generateLensTop ( SLfloat  radius)
private

Generate the top (back) part of the lens.

Parameters
radiusof the lens
Returns
x the x coordinate of the last point of the bulge

Definition at line 272 of file SLLens.cpp.

273 {
274  // Point
275  SLVec3f p;
276  SLfloat x = _diameter / 2;
277  SLfloat y; // = yStart2;
278 
279  SLfloat sagitta = calcSagitta(radius);
280  SLint halfStacks = _stacks / 2;
281 
282  // check if the lens has a deep
283  if ((sagitta >= 0))
284  {
285  SLfloat yStart2 = _thickness;
286  SLfloat radiusAmount2 = radius;
287  SLfloat yTranslate2 = -radius + sagitta;
288 
289  SLfloat betaAsin = _diameter / (2.0f * radius);
290  betaAsin = (betaAsin > 1) ? 1 : betaAsin; // correct rounding errors
291  betaAsin = (betaAsin < -1) ? -1 : betaAsin; // correct rounding errors
292  SLfloat betaRAD = 2.0f * (SLfloat)asin(betaAsin);
293  SLfloat currentBetaRAD = Utils::HALFPI - (betaRAD * 0.5f);
294 
295  // settings for negative radius
296  if (radius < 0)
297  {
298  currentBetaRAD = -Utils::HALFPI - (betaRAD * 0.5f);
299  yStart2 = sagitta + _thickness;
300  radiusAmount2 = -radius;
301  yTranslate2 = -radius;
302  }
303 
304  SLfloat currentBetaDEG = currentBetaRAD * Utils::RAD2DEG;
305  SLfloat dBetaRAD = (betaRAD * 0.5f) / halfStacks;
306 
307  // set start point
308  y = yStart2;
309  p.x = (SLfloat)x;
310  p.y = (SLfloat)y;
311  p.z = 0;
312  _revPoints.push_back(p);
313  if (_pointOutput) cout << currentBetaDEG << " x: " << x << " y: " << y << endl;
314 
315  // draw top part of the lens
316  for (int i = 0; i < halfStacks; i++)
317  {
318  // change angle
319  currentBetaRAD += dBetaRAD;
320  currentBetaDEG = currentBetaRAD * Utils::RAD2DEG;
321 
322  // calc y
323  y = (((sin(currentBetaRAD)) * (radiusAmount2)) + yTranslate2 + _thickness);
324 
325  // calc x
326  if ((i + 1 == halfStacks))
327  {
328  x = 0;
329  if (radius < 0)
330  y = _thickness;
331  }
332  else
333  x = cos(currentBetaRAD) * radiusAmount2;
334 
335  if (_pointOutput) cout << currentBetaDEG << " x: " << x << " y: " << y << endl;
336 
337  // set point
338  p.x = x;
339  p.y = y;
340  p.z = 0;
341  _revPoints.push_back(p);
342  }
343  }
344  else
345  {
346  SLfloat cutX = x / halfStacks;
347 
348  // Draw plane
349  for (int i = halfStacks - 1; i >= 0; i--)
350  {
351  x = cutX * i;
352  y = _thickness;
353 
354  // set point
355  p.x = x;
356  p.y = y;
357  p.z = 0;
358  _revPoints.push_back(p);
359  if (_pointOutput) cout << "0"
360  << " x: " << x << " y: " << y << " _T" << endl;
361  }
362  }
363  return x;
364 }
SLfloat _thickness
The space between the primary planes of lens sides.
Definition: SLLens.h:72

◆ initLens()

void SLLens::initLens ( SLfloat  diopterBot,
SLfloat  diopterTop,
SLfloat  diameter,
SLfloat  thickness,
SLuint  stacks,
SLuint  slices,
SLMaterial mat 
)
private

Initialize the lens.

Parameters
diopterBotSLfloat The diopter of the bot (front) part of the lens
diopterTopSLfloat The diopter of the top (back) part of the lens
diameterSLfloat The diameter of the lens
thicknessSLfloat d The space between the primary planes of lens sides
stacksSLint
slicesSLint
matSLMaterial* The Material of the lens

Definition at line 114 of file SLLens.cpp.

121 {
122  assert(slices >= 3 && "Error: Not enough slices.");
123  assert(slices > 0 && "Error: Not enough stacks.");
124 
125  _diameter = diameter;
126  _thickness = thickness;
127  _stacks = stacks;
128  _slices = slices;
129  _pointOutput = false; // cout the coordinates of each point of the lens
130 
131  // Gullstrand-Formel
132  // D = D1 + D2 - delta * D1 * D2
133 
134  // calc radius
135  SLfloat nOut = 1.00; // kn material outside lens
136  SLfloat nLens = mat->kn(); // kn material of the lens
137 
138  // calc radius
139  _radiusBot = (SLfloat)((nLens - nOut) / diopterBot) * _diameter;
140  _radiusTop = (SLfloat)((nOut - nLens) / diopterTop) * _diameter;
141 
142  if (_pointOutput)
143  cout << " radiusBot: " << _radiusBot << " radiusTop: " << _radiusTop << endl;
144 
145  // generate lens
147 }
SLfloat _radiusTop
The radius of the top (back) side of the lens.
Definition: SLLens.h:74
void generateLens(SLfloat radiusBot, SLfloat radiusTop, SLMaterial *mat)
Generate the lens with given front and back radius.
Definition: SLLens.cpp:155
SLfloat _radiusBot
The radius of the bot (front) side of the lens.
Definition: SLLens.h:73
SLuint _slices
NO. of slices.
Definition: SLRevolver.h:61

Member Data Documentation

◆ _diameter

SLfloat SLLens::_diameter
private

The diameter of the lens.

Definition at line 71 of file SLLens.h.

◆ _pointOutput

SLbool SLLens::_pointOutput
private

debug helper

Definition at line 75 of file SLLens.h.

◆ _radiusBot

SLfloat SLLens::_radiusBot
private

The radius of the bot (front) side of the lens.

Definition at line 73 of file SLLens.h.

◆ _radiusTop

SLfloat SLLens::_radiusTop
private

The radius of the top (back) side of the lens.

Definition at line 74 of file SLLens.h.

◆ _thickness

SLfloat SLLens::_thickness
private

The space between the primary planes of lens sides.

Definition at line 72 of file SLLens.h.


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