-
Notifications
You must be signed in to change notification settings - Fork 2
/
GeometricOptics.h
690 lines (616 loc) · 23.5 KB
/
GeometricOptics.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
//
// Created by Ryan.Zurrin001 on 12/16/2021.
//
#ifndef PHYSICSFORMULA_GEOMETRICOPTICS_H
#define PHYSICSFORMULA_GEOMETRICOPTICS_H
#include <map>
#include "Constants.h"
#include <iostream>
using namespace std;
static int geometricOptics_objectCount = 0;
static struct RefractionIndexes
{
//gases at 0 C, 1 atm
const ld AIR = 1.000293;
const ld CARBON_DIOXIDE = 1.00045;
const ld HYDROGEN = 1.000139;
const ld OXYGEN = 1.000271;
//Liquids at 20 C
const ld BENZENE = 1.501;
const ld CARBON_DISULFIDE = 1.628;
const ld CARBON_TETRACHLORIDE = 1.461;
const ld ETHANOL = 1.361;
const ld GLYCERINE = 1.473;
const ld WATER_FRESH = 1.333;
//Solids at 20 C
const ld DIAMOND = 2.419;
const ld FLUORITE = 1.434;
const ld GLASS_CROWN = 1.52;
const ld GLASS_FLINT = 1.66;
const ld ICE = 1.309;
const ld POLYSTYRENE = 1.49;
const ld PLEXIGLAS = 1.51;
const ld QUARTZ_CRYSTALLINE = 1.544;
const ld QUARTZ_FUSED = 1.458;
const ld SODIUM_CHLORIDE = 1.544;
const ld ZIRCON = 1.923;
}refraction;
static std::multimap<std::string, ld> refractions {
{"AIR", 1.0},
{"AIR", 1.00},
{"AIR", 1.000},
{"AIR", 1.0003},
{"AIR", 1.00029},
{"AIR", 1.000293},
{"CARBON_DIOXIDE~",1.0},
{"CARBON_DIOXIDE",1.00},
{"CARBON_DIOXIDE~",1.000},
{"CARBON_DIOXIDE",1.0005},
{"CARBON_DIOXIDE",1.00045},
{"HYDROGEN",1.0},
{"HYDROGEN",1.00},
{"HYDROGEN",1.000},
{"HYDROGEN",1.0001},
{"HYDROGEN",1.00014},
{"HYDROGEN",1.000139},
{"OXYGEN",1.0},
{"OXYGEN",1.00},
{"OXYGEN",1.000},
{"OXYGEN",1.000},
{"OXYGEN",1.0003},
{"OXYGEN",1.00027},
{"BENZENE",1.5},
{"BENZENE",1.50},
{"BENZENE",1.501},
{"BENZENE",1.502},
{"CARBON_DISULFIDE",1.6},
{"CARBON_DISULFIDE",1.63},
{"CARBON_DISULFIDE",1.628},
{"CARBON_DISULFIDE",1.6279},
{"CARBON_TETRACHLORIDE",1.50},
{"CARBON_TETRACHLORIDE",1.46},
{"CARBON_TETRACHLORIDE",1.461},
{"CARBON_TETRACHLORIDE",1.4614},
{"ETHANOL",1.4},
{"ETHANOL",1.36},
{"ETHANOL",1.361},
{"ETHANOL",1.3614},
{"GLYCERINE",1.5},
{"GLYCERINE",1.47},
{"GLYCERINE",1.473},
{"GLYCERINE",1.4734},
{"WATER_FRESH",1.3},
{"WATER_FRESH Red 660nm",1.331},
{"WATER_FRESH Orange 610nm",1.332},
{"WATER_FRESH Yellow 580nm",1.333},
{"WATER_FRESH Green 550nm",1.335},
{"WATER_FRESH",1.33},
{"WATER_FRESH Blue 470nm",1.338},
{"WATER_FRESH Violet 410nm",1.342},
{"DIAMOND",2.4},
{"DIAMOND Red 660nm",2.41},
{"DIAMOND Orange 610nm",2.415},
{"DIAMOND Yellow 580nm",2.417},
{"DIAMOND",2.419},
{"DIAMOND",2.42},
{"DIAMOND Green 550nm",2.426},
{"DIAMOND",2.3},
{"DIAMOND",2.36},
{"DIAMOND",2.38},
{"DIAMOND",2.42},
{"DIAMOND Blue 470nm",2.444},
{"DIAMOND Violet 410nm",2.458},
{"FLUORITE",1.4},
{"FLUORITE",1.43},
{"FLUORITE",1.434},
{"FLUORITE",1.4345},
{"GLASS_CROWN",1.5},
{"GLASS_CROWN Red 660nm",1.512},
{"GLASS_CROWN Orange 610nm",1.514},
{"GLASS_CROWN Yellow 580nm",1.518},
{"GLASS_CROWN Green 550nm",1.519},
{"GLASS_CROWN",1.52},
{"GLASS_CROWN Blue 470nm",1.524},
{"GLASS_CROWN",1.529},
{"GLASS_CROWN Violet 410nm",1.530},
{"GLASS_FLINT",1.7},
{"GLASS_FLINT",1.66},
{"GLASS_FLINT",1.664},
{"ICE",1.3},
{"ICE",1.31},
{"ICE",1.309},
{"ICE",1.3091},
{"POLYSTYRENE",1.5},
{"POLYSTYRENE",1.49},
{"POLYSTYRENE",1.491},
{"POLYSTYRENE",1.495},
{"PLEXIGLAS",1.5},
{"PLEXIGLAS",1.51},
{"PLEXIGLAS",1.512},
{"PLEXIGLAS",1.513},
{"QUARTZ_CRYSTALLINE",1.5},
{"QUARTZ_CRYSTALLINE",1.54},
{"QUARTZ_CRYSTALLINE",1.544},
{"QUARTZ_CRYSTALLINE",1.5443},
{"QUARTZ_FUSED",1.5},
{"QUARTZ_FUSED",1.45},
{"QUARTZ_FUSED",1.458},
{"QUARTZ_FUSED",1.457},
{"QUARTZ_FUSED",1.459},
{"QUARTZ_FUSED",1.456},
{"SODIUM_CHLORIDE",1.5},
{"SODIUM_CHLORIDE",1.54},
{"SODIUM_CHLORIDE",1.544},
{"SODIUM_CHLORIDE",1.543},
{"ZIRCON",1.9},
{"ZIRCON",1.92},
{"ZIRCON",1.923},
{"ZIRCON",1.924}
};
template<typename T>
static void printVec(const T& t) {
std::copy(t.cbegin(), t.cend(), ostream_iterator<typename T::value_type>(std::cout, ", "));
}//end printVector
template<typename K, typename V>
static bool findMedium(std::vector<K> & vec, std::multimap<K, V> mapOfElemen, V value)
{
bool bResult = false;
auto it = mapOfElemen.begin();
while(it != mapOfElemen.end())
{
if(it->second == value)
{
bResult = true;
vec.push_back(it->first);
}
it++;
}
return bResult;
}//end searchMapByValue
template<typename K, typename V>
static void printMedium(std::multimap<K,V> m, const V val)
{
std::cout << "looking for value: "<< val<<endl;
std::vector<std::string> results;
bool tests = findMedium(results, m, val);
if(tests)
{
std::cout<<"Keys with value "<< val<< " are:"<<std::endl;
printVec(results);
}
else
{
std::cout<<"No Key is found with the given value"<<std::endl;
}
}//end printMapByValue
class GeometricOptics :
public ElectromagneticWaves
{
public:
GeometricOptics()
{
countIncrease();
}
/**
* @brief copy constructor
*/
GeometricOptics(const GeometricOptics& t)
{
countIncrease();
}
/**
* #brief move constructor
*/
GeometricOptics(GeometricOptics&& t) noexcept
{
countIncrease();
}
/**
* @brief copy assignment operator
*/
GeometricOptics& operator=(const GeometricOptics& t)
{
if (this != &t)
{
countIncrease();
}
return *this;
}
static void show_objectCount() { std::cout
<< "\n geometric optics object count: "
<< geometricOptics_objectCount << std::endl; }
static int get_objectCount() { return geometricOptics_objectCount; }
~GeometricOptics(){}
/// <summary>
/// Calculates the index of refraction (n) where v is the observed speed of
/// light in the material.
/// </summary>
/// <param name="v">The observed speed of light in a material.</param>
/// <returns>the index of refraction (n) is unit less</returns>
static ld indexOfRefraction(const ld v, int precision);
/// <summary>
/// Calculates the speeds of the light from a know refraction index of n
/// </summary>
/// <param name="n">The refraction index.</param>
/// <returns>the speed of the light through a substance or material</returns>
static ld speedOfLightFromRefractionIndex(const ld n);
/// <summary>
/// calculates the index of refraction medium 2.
/// </summary>
/// <param name="n1">The index of refraction from the incident ray.</param>
/// <param name="incidentAng1">The incident ray angle.</param>
/// <param name="angRefraction2">The angle of the refracted ray.</param>
/// <returns>index of refraction for medium 2</returns>
static ld indexOfRefractionMedium2(const ld n1, const ld incidentAng1, const ld angRefraction2, int precision);
/// <summary>
/// calculates the index of refraction medium 1.
/// </summary>
/// <param name="n2">The index of refraction of material 2.</param>
/// <param name="incidentAng1">The incident angle .</param>
/// <param name="angRefraction2">The angle of refraction.</param>
/// <param name="precision">The precision.</param>
/// <returns>index of refraction for medium 1</returns>
static ld indexOfRefractionMedium1(const ld n2, const ld incidentAng1, const ld angRefraction2, int precision);
/// <summary>
/// Calculates the angle of refraction.
/// </summary>
/// <param name="n1">The index of refraction from the incident ray.</param>
/// <param name="n2">The index of refraction from refracted ray.</param>
/// <param name="incidentAng1">The incident angle.</param>
/// <returns>the angle of refraction</returns>
static ld angleOfRefraction(const ld n1, const ld n2, const ld incidentAng1);
/// <summary>
/// Calculates the incident angle.
/// </summary>
/// <param name="n1">The index of refraction from the incident ray.</param>
/// <param name="n2">The index of refraction from refracted ray.</param>
/// <param name="angRefraction2">The angle of refraction.</param>
/// <returns>the incident angle</returns>
static ld incidentAngle(const ld n1, const ld n2, const ld angRefraction2);
/// <summary>
/// Calculates the critical angle for conditions {n1 > n2}
/// </summary>
/// <param name="n1">The n1.</param>
/// <param name="n2">The n2.</param>
/// <returns>the critical angle</returns>
static ld criticalAngle(const ld n1, const ld n2);
/// <summary>
/// Waves the length from index refraction.
/// </summary>
/// <param name="waveLFromSourceRay">The wave l from source ray.</param>
/// <param name="n">The n.</param>
/// <returns></returns>
static ld waveLength_fromIndexRefraction(const ld waveLFromSourceRay, const ld n);
/// <summary>
/// Suppose a person stands in front of a mirror their eyes are floorToEyes(m)
/// above the floor, and the top of their head is eyesToTopHea m higher.
/// Find the height above the floor of the top and bottom of the smallest mirror
/// in which he can see both the top of his head and his feet. How is this
/// distance related to the man’s height?
/// </summary>
/// <param name="floorToEyes">The floor to eyes.</param>
/// <param name="eyesToTopHead">The eyes to top head.</param>
/// <returns></returns>
static std::map<std::string, ld> heightOfMirror(const ld floorToEyes, const ld eyesToTopHead);
/// <summary>
/// Components of some computers communicate with each other through optical
/// fibers having an index of refraction n=1.55 but this can be generalized
/// to any matter having a refraction index of n. What time in seconds
/// is required for a signal to travel d m through that material?
/// </summary>
/// <param name="n">The refraction index.</param>
/// <param name="d">The distance.</param>
/// <returns>time for signal to travel</returns>
static ld timeForSignalToTravel(const ld n, const ld d);
/// <summary>
/// Calculates the powers of the lens, which is the inverse of its focal
/// length f. The units of a lens power is in diopters(D) which is 1/m or
/// 1m^-1
/// </summary>
/// <param name="f">The focal length.</param>
/// <returns>diopters of lens</returns>
static ld powerOfLens(const ld f);
/// <summary>
/// Calculates the focal length of a lens having a power of P diopters
/// </summary>
/// <param name="P">The power of the lens.</param>
/// <returns>the focal length</returns>
static ld focalLength(const ld P);
/// <summary>
/// Focals the length.
/// </summary>
/// <param name="m">The magnification.</param>
/// <param name="d_o">The object distance.</param>
/// <returns>focal length</returns>
static ld focalLength(const ld m, const ld d_o);
/// <summary>
/// Angles the and distance of bounced laser to sensor.
/// </summary>
/// <param name="disFromLas2Mirror">The dis from las2 mirror.</param>
/// <param name="disSouthSensor">The dis south sensor.</param>
/// <param name="angleOffBy">The angle off by.</param>
/// <returns></returns>
static std::map<std::string, ld> angleAndDistanceOfBouncedLaserToSensor(
const ld disFromLas2Mirror, const ld disSouthSensor, const ld angleOffBy);
/// <summary>
/// A scuba diver training in a pool looks at his instructor. What angle
/// does the ray from the instructor’s face make with the perpendicular to
/// the water at the point where the ray enters? The angle between the ray
/// in the water and the perpendicular to the water is angRefrac2∘.
/// </summary>
/// <param name="n1">The n1.</param>
/// <param name="n2">The n2.</param>
/// <param name="angRefrac2">The refraction angle2.</param>
/// <returns></returns>
static ld incidentRayToMaterial(const ld n1, const ld n2, const ld angRefrac2);
/// <summary>
/// Calculates the image distance with a known focal lenght of f and the
/// objects distance of dObj
/// </summary>
/// <param name="dObj">The objects distance.</param>
/// <param name="f">The focal distance.</param>
/// <returns>the image distance</returns>
static ld imageDistance_diRaytracing(const ld dObj, const ld f);
/// <summary>
/// An object h_o units high is held d_o units from a person’s cornea, and
/// its reflected image is measured to be h_i units high.
/// calculate Where the image is.
/// </summary>
/// <param name="d_o">The object distance.</param>
/// <param name="h_i">The image height.</param>
/// <param name="h_o">The object height.</param>
/// <returns>image distance, or position of image</returns>
static auto imageDistance_hihodo(const ld d_o, const ld h_i, const ld h_o);
/// <summary>
/// Calculates the Magnification.
/// </summary>
/// <param name="di">The distance of image.</param>
/// <param name="dObj">The distance of object.</param>
/// <returns></returns>
static ld magnification(const ld di, const ld dObj);
/// <summary>
/// Calculates the index of refraction of a substance that has a critical
/// angle of cA° when submerged in a substance, which has an index of
/// refraction of n2?
/// </summary>
/// <param name="cA">The known critical angle.</param>
/// <param name="n2">The index known index of refraction.</param>
/// <returns>the unknown index of refraction of substance</returns>
static ld indexOfRefractionFromCriticalAngle(const ld cA, const ld n2);
/// <summary>
/// If a converging lens forms a real, inverted image d_i units to the right
/// of the lens when the object is placed d_o units to the left of a lens,
/// determine the focal length of the lens.
/// </summary>
/// <param name="d_i">The distance image makes.</param>
/// <param name="d_o">The distance object is placed.</param>
/// <returns>the focal length</returns>
static ld focalLength_ConvergingLens_dido(const ld d_i, const ld d_o);
/// <summary>
/// Calculates the focal length from the radius of curvature
/// </summary>
/// <param name="R">The r.</param>
/// <returns></returns>
static ld focalLength_R(const ld R);
/// <summary>
/// Objects the distance.
/// </summary>
/// <param name="f">The f.</param>
/// <param name="d_i">The d i.</param>
/// <returns></returns>
static ld objectDistance(const ld f, const ld d_i);
/// <summary>
/// Calculates the radius of curvature.
/// </summary>
/// <param name="f">The focal length.</param>
/// <returns></returns>
static ld radiusOfCurvature(const ld f);
/// <summary>
/// Calculate the intensity of IR radiation in W/m2 from a space heater
/// projected by a concave mirror on a person d_i units away. Assume that
/// the heating element radiates P Watts and has an area of A units^2, and
/// that half of the radiated power is reflected and focused by the mirror
/// </summary>
/// <param name="d_i">The image distance, how far a person is standing.</param>
/// <param name="d_o">The object distance.</param>
/// <param name="P">The power.</param>
/// <param name="A">the area of mirror.</param>
/// <returns> Intensity (W/m^2)</returns>
static ld intensityOfIR_radiation(const ld d_i, const ld d_o, const ld P, const ld A);
private:
static void countIncrease() { geometricOptics_objectCount += 1; }
static void countDecrease() { geometricOptics_objectCount -= 1; }
};
#endif //PHYSICSFORMULA_GEOMETRICOPTICS_H
//=============================================================================
//in-line class Implementation
inline ld GeometricOptics::indexOfRefraction(const ld v, int precision = 3)
{
if (precision == 1)
{
ld scale = 0.1;
ld a = constants::LIGHT_SPEED / v;
return floor(a/scale+.5)* scale;
}
if (precision == 2)
{
ld scale = 0.01;
ld a = constants::LIGHT_SPEED / v;
return floor(a/scale+.5)* scale;
}
if (precision == 3)
{
ld scale = 0.001;
ld a = constants::LIGHT_SPEED / v;
return floor(a/scale+.5)* scale;
}
if (precision == 4)
{
ld scale = 0.0001;
ld a = constants::LIGHT_SPEED / v;
return floor(a/scale+.5)* scale;
}
else
return constants::LIGHT_SPEED / v;;
}
inline ld GeometricOptics::speedOfLightFromRefractionIndex(const ld n)
{
return constants::LIGHT_SPEED / n;
}
inline ld GeometricOptics::indexOfRefractionMedium2(const ld n1, const ld incidentAng1, const ld angRefraction2, int precision = 3)
{
if (precision == 1)
{
ld val = n1 * (sin(incidentAng1 * constants::RADIAN) / sin(angRefraction2 * constants::RADIAN));
ld scale = .1;
ld v = floor(val / scale + .5) * scale;
return v;
}
if (precision == 2)
{
ld val = n1 * (sin(incidentAng1 * constants::RADIAN) / sin(angRefraction2 * constants::RADIAN));
ld scale = .01;
return floor(val/scale+.5)*scale;
}
if (precision == 3)
{
ld val = n1 * (sin(incidentAng1 * constants::RADIAN) / sin(angRefraction2 * constants::RADIAN));
ld scale = .001;
return floor(val/scale+.5)*scale;
}
if (precision == 4)
{
ld val = n1 * (sin(incidentAng1 * constants::RADIAN) / sin(angRefraction2 * constants::RADIAN));
ld scale = .0001;
return floor(val / scale + .5) * scale;
}
else
return n1 * (sin(incidentAng1 * constants::RADIAN) / sin(angRefraction2 * constants::RADIAN));
}
inline ld GeometricOptics::indexOfRefractionMedium1(const ld n2, const ld incidentAng1, const ld angRefraction2, int precision)
{
if (precision == 1)
{
ld val = n2 * (sin(angRefraction2 * constants::RADIAN) / sin(incidentAng1 * constants::RADIAN));
ld scale = .1;
ld v = floor(val / scale + .5) * scale;
return v;
}
if (precision == 2)
{
ld val = n2 * (sin(angRefraction2 * constants::RADIAN) / sin(incidentAng1 * constants::RADIAN));;
ld scale = .01;
return floor(val/scale+.5)*scale;
}
if (precision == 3)
{
ld val = n2 * (sin(angRefraction2 * constants::RADIAN) / sin(incidentAng1 * constants::RADIAN));
ld scale = .001;
return floor(val/scale+.5)*scale;
}
if (precision == 4)
{
ld val = n2 * (sin(angRefraction2 * constants::RADIAN) / sin(incidentAng1 * constants::RADIAN));
ld scale = .0001;
return floor(val / scale + .5) * scale;
}
else
return n2 * (sin(incidentAng1 * constants::RADIAN) / sin(incidentAng1 * constants::RADIAN));
}
inline ld GeometricOptics::angleOfRefraction(const ld n1, const ld n2, const ld incidentAng1)
{
ld temp = (n1 / n2) * sin(incidentAng1*constants::RADIAN);
return asin(temp)*constants::DEGREE;
}
inline ld GeometricOptics::incidentAngle(const ld n1, const ld n2, const ld angRefraction2)
{
ld temp = (n2 / n1) * sin(angRefraction2 * constants::RADIAN);
return asin(temp) * constants::DEGREE;
}
inline ld GeometricOptics::criticalAngle(const ld n1, const ld n2)
{
return asin(n2/n1)*constants::DEGREE;
}
inline ld GeometricOptics::waveLength_fromIndexRefraction(const ld waveLFromSourceRay, const ld n)
{
return waveLFromSourceRay / n;
}
inline std::map<std::string, ld> GeometricOptics::heightOfMirror(const ld floorToEyes, const ld eyesToTopHead)
{
map<string, ld> result;
result["floor to bottom of mirror"] = floorToEyes / 2.0;//height from floor to bottom of mirror
result["1/2 from eyes to top of head"] = eyesToTopHead / 2.0;
result["height of person"] = floorToEyes + eyesToTopHead;
result["length of mirror"] = result.at("height of person") -
result.at("floor to bottom of mirror") -
result.at("1/2 from eyes to top of head");
result["floor to top of mirror"] = result.at("floor to bottom of mirror") +
result.at("length of mirror");
return result;
}
inline ld GeometricOptics::timeForSignalToTravel(const ld n, const ld d)
{
return (d* n)/constants::LIGHT_SPEED;//s
}
inline ld GeometricOptics::powerOfLens(const ld f)
{
return 1 / f;//diopters = D
}
inline ld GeometricOptics::focalLength(const ld P)
{
return 1.0 / P;
}
inline ld GeometricOptics::focalLength(const ld m, const ld d_o)
{
return (1 / d_o) - (1 / (m * d_o));
}
inline std::map<std::string, ld> GeometricOptics::angleAndDistanceOfBouncedLaserToSensor(const ld disFromLas2Mirror, const ld disSouthSensor, const ld angleOffBy)
{
std::map<string, ld> results;
ld angle = (atan(disSouthSensor / disFromLas2Mirror) * constants::DEGREE) / 2.0;
results["angle with respect to due west"] = angle;
ld offBy = disFromLas2Mirror * tan((2.0 * (angle + angleOffBy))*constants::RADIAN);
results["distance between laser and point south"] = offBy;
results["how far need to move the light sensor"] = offBy - disSouthSensor;
return results;
}
inline ld GeometricOptics::incidentRayToMaterial(const ld n1, const ld n2, const ld angRefrac2)
{
return asin((n2 * sin(angRefrac2*constants::RADIAN)) / n1) * constants::DEGREE;
}
inline ld GeometricOptics::imageDistance_diRaytracing(const ld dObj, const ld f)
{
return (f * dObj) / (dObj - f);
}
inline auto GeometricOptics::imageDistance_hihodo(const ld d_o, const ld h_i, const ld h_o)
{
return -(d_o * h_i) / h_o;
}
inline ld GeometricOptics::magnification(const ld di, const ld dObj)
{
return -(di / dObj);
}
inline ld GeometricOptics::indexOfRefractionFromCriticalAngle(const ld cA, const ld n2)
{
return n2 / sin(cA * constants::RADIAN);
}
inline ld GeometricOptics::focalLength_ConvergingLens_dido(const ld d_i, const ld d_o)
{
return (d_i * d_o) / (d_i + d_o);
}
inline ld GeometricOptics::focalLength_R(const ld R)
{
return R / 2.0;
}
inline ld GeometricOptics::objectDistance(const ld f, const ld d_i)
{
return 1.0 / ((1.0 / f) - (1.0 / d_i));
}
inline ld GeometricOptics::radiusOfCurvature(const ld f)
{
return 2.0 * f;
}
inline ld GeometricOptics::intensityOfIR_radiation(const ld d_i, const ld d_o, const ld P, const ld A)
{
return P * pow(d_o, 2) / 2 / (A / 100) / pow(d_i, 2);
}