1. Alexander Konovalov
  2. poissonraytracer

Commits

Alexander Konovalov  committed f852229

Optional configuration values

  • Participants
  • Parent commits f49ae9c
  • Branches default

Comments (0)

Files changed (3)

File experiments/scattering_diagram/mc_alister.cfg

View file
 refractiveIndexStep          = 0.0001;
 outputFileName               = "results/ns.dat";
 
-numSteps		                 = 30;
-
-scatteringDiagramPoints      = 20;
+scatteringDiagramPoints      = 36;
 scatteringOutputFileName     = "results/scattering.dat";

File rt/main.cpp

View file
 void LoadConfig(const char* path, Config* cfg) {
   libconfig::Config configuration;
   configuration.readFile(path);
-  const libconfig::Setting& root = configuration.getRoot();
 
-  cfg->tubeLength = root["tubeLength"];
-  cfg->tubeRadius = root["tubeRadius"];
-  cfg->sourceRadius = root["sourceRadius"];
-  cfg->diaphragmDistance = root["diaphragmDistance"];
-  cfg->diaphragmRadius = root["diaphragmRadius"];
-  cfg->packingFactor = root["packingFactor"];
-  cfg->averageSphereRadius  = root["averageSphereRadius"];
-  cfg->sphereRadiusDeviation = root["sphereRadiusDeviation"];
-  cfg->refractionIndexDeviation = root["refractionIndexDeviation"];
-  cfg->targetPrecision = root["targetPrecision"];
-  cfg->minPhotons = root["minPhotons"];
+  cfg->tubeLength = 0.0762;
+  configuration.lookupValue("tubeLength", cfg->tubeLength);
 
-  cfg->minRefractiveIndex = root["minRefractiveIndex"];
-  cfg->maxRefractiveIndex = root["maxRefractiveIndex"];
-  cfg->refractiveIndexStep = root["refractiveIndexStep"];
+  cfg->tubeRadius = 0.0762;
+  configuration.lookupValue("tubeRadius", cfg->tubeRadius);
 
-  const char* output = root["outputFileName"];
+  cfg->sourceRadius = 0.0762;
+  configuration.lookupValue("sourceRadius", cfg->sourceRadius);
+
+  cfg->diaphragmDistance = 20.1168;
+  configuration.lookupValue("diaphragmDistance", cfg->diaphragmDistance);
+
+  cfg->diaphragmRadius = 0.0762;
+  configuration.lookupValue("diaphragmRadius", cfg->diaphragmRadius);
+
+  cfg->packingFactor = 0.70;
+  configuration.lookupValue("packingFactor", cfg->packingFactor);
+
+  cfg->averageSphereRadius = 1e-3;
+  configuration.lookupValue("averageSphereRadius", cfg->averageSphereRadius);
+
+  cfg->sphereRadiusDeviation = 0.00001;
+  configuration.lookupValue("sphereRadiusDeviation", cfg->sphereRadiusDeviation);
+
+  cfg->refractionIndexDeviation = 0.0002;
+  configuration.lookupValue("refractionIndexDeviation", cfg->refractionIndexDeviation);
+
+  cfg->targetPrecision = 0.01;
+  configuration.lookupValue("targetPrecision", cfg->targetPrecision);
+
+  cfg->minPhotons = 100;
+  configuration.lookupValue("minPhotons", cfg->minPhotons);
+
+  cfg->minRefractiveIndex = 0.980;
+  configuration.lookupValue("minRefractiveIndex", cfg->minRefractiveIndex);
+
+  cfg->maxRefractiveIndex = 1.020;
+  configuration.lookupValue("maxRefractiveIndex", cfg->maxRefractiveIndex);
+
+  cfg->refractiveIndexStep = 0.0001;
+  configuration.lookupValue("refractiveIndexStep", cfg->refractiveIndexStep);
+
+  const char* output = "";
+  configuration.lookupValue("outputFileName", output);
   cfg->outputFileName = output;
 
-  cfg->scatteringDiagramPoints = root["scatteringDiagramPoints"];
-  const char* scatteringOutputFileName = root["scatteringOutputFileName"];
+  cfg->scatteringDiagramPoints = 0.0762;
+  configuration.lookupValue("scatteringDiagramPoints", cfg->scatteringDiagramPoints);
+
+  const char* scatteringOutputFileName = "";
+  configuration.lookupValue("scatteringOutputFileName", scatteringOutputFileName);
   cfg->scatteringOutputFileName = scatteringOutputFileName;
 }
 

File rt/simulator.cpp

View file
 const float kFloatEpsilon = std::numeric_limits<float>::epsilon();
 
 void UpdateScatteringData(std::vector<float>& scatteringData, Eigen::Vector3f& direction) {
-  float radialPart = direction.head<2>().norm();
-  float zPart = direction[2];
-  float exitAngle = atan2(radialPart, zPart);
-  unsigned scatteringPoint = (unsigned) ((exitAngle / (M_PI)) * scatteringData.size());
-  scatteringData[scatteringPoint]++;
+  if (scatteringData.size() != 0) {
+    float radialPart = direction.head<2>().norm();
+    float zPart = direction[2];
+    float exitAngle = atan2(radialPart, zPart);
+    unsigned scatteringPoint = (unsigned) ((exitAngle / (M_PI)) * scatteringData.size());
+    scatteringData[scatteringPoint]++;
+  }
 }
 
 }