void Optimize() { ROOT::Minuit2::Minuit2Minimizer min2; min2.SetMaxFunctionCalls(1000000); min2.SetMaxIterations(100000); min2.SetTolerance(0.001); ROOT::Math::Functor f(&Func, 3); double step[3] = {0.01, 0.01, 0.01}; double par[3] = {3*mm, -1/(50*mm), 0.}; double pmin[3] = {1*mm, -1/(20*mm), -3}; double pmax[3] = {5*mm, -1/(100*mm), 1}; min2.SetFunction(f); min2.SetLimitedVariable(0, "thickness", par[0], step[0], pmin[0], pmax[0]); min2.SetLimitedVariable(1, "curvature", par[1], step[1], pmin[1], pmax[1]); min2.SetLimitedVariable(2, "conic constant", par[2], step[2], pmin[2], pmax[2]); min2.Minimize(); const double* x = min2.X(); std::cout << "Thickness = " << x[0]/mm << " (mm)\n"; std::cout << "Raduis = " << (1/x[1])/mm << " (mm)\n"; std::cout << "Conic = " << x[2] << "\n"; DrawPSF(); gPad = 0; gOpticsManager->GetTopVolume()->Draw("ogl"); DrawRays(); }
void Sphere::DiscreteSource(sf::RenderWindow * window) { double dist = c2.center.x - c1.center.x; double* param = getParam(c1.r, c2.r, dist); Ray* ray = new Ray[200]; double x, y, t; int i = 0; double step = 2 * param[0] /10; // cout <<"step"<< step << "param"<<param[0]<< " "<<param[1] << endl; /*t = -param[0]+0.1; x = std::cos(t) * c1.r; y = std::sin(t) * c1.r; ray[i] = Ray(Vector2(70, 250), Vector2(c1.center.x + x, 250 + y)); DrawRays(ray[i], window);*/ for (t = -param[0]; t <= param[0]; t += 0.02) { cout << "step" << step <<" "<< "t" << t << endl; x = std::cos(t) * c1.r; y = std::sin(t) * c1.r; ray[i]= Ray(Vector2(0,250), Vector2(c1.center.x + x, 250 + y)); // ray[i].print(); DrawRays(ray[i], window); i++; cout << i << endl; } }
void GLUTRedraw(void) { // Check scene if (!scene) return; // Set viewing transformation viewer->Camera().Load(); // Clear window RNRgb background = scene->Background(); glClearColor(background.R(), background.G(), background.B(), 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Load lights LoadLights(scene); // Draw camera if (show_camera) { glDisable(GL_LIGHTING); glColor3d(1.0, 1.0, 1.0); glLineWidth(5); DrawCamera(scene); glLineWidth(1); } // Draw lights if (show_lights) { glDisable(GL_LIGHTING); glColor3d(1.0, 1.0, 1.0); glLineWidth(5); DrawLights(scene); glLineWidth(1); } // Draw rays if (show_rays) { glDisable(GL_LIGHTING); glColor3d(0.0, 1.0, 0.0); glLineWidth(3); DrawRays(scene); glLineWidth(1); } // Draw rays if (show_photons) { glDisable(GL_LIGHTING); glColor3d(1.0, 1.0, 1.0); glLineWidth(1); DrawPhotonPaths(scene); glLineWidth(1); } // Draw rays if (show_global_samples) { glDisable(GL_LIGHTING); glColor3d(1.0, 1.0, 1.0); glLineWidth(1); DrawGlobalSamples(scene); glLineWidth(1); } // Draw rays if (show_caustic_samples) { glDisable(GL_LIGHTING); glColor3d(1.0, 1.0, 1.0); glLineWidth(1); DrawCausticSamples(scene); glLineWidth(1); } // Draw scene nodes if (show_shapes) { glEnable(GL_LIGHTING); R3null_material.Draw(); DrawShapes(scene, scene->Root()); R3null_material.Draw(); } // Draw bboxes if (show_bboxes) { glDisable(GL_LIGHTING); glColor3d(1.0, 0.0, 0.0); DrawBBoxes(scene, scene->Root()); } // Draw frame time if (show_frame_rate) { char buffer[128]; static RNTime last_time; double frame_time = last_time.Elapsed(); last_time.Read(); if ((frame_time > 0) && (frame_time < 10)) { glDisable(GL_LIGHTING); glColor3d(1.0, 1.0, 1.0); sprintf(buffer, "%.1f fps", 1.0 / frame_time); DrawText(R2Point(100, 100), buffer); } } // Capture screenshot image if (screenshot_image_name) { if (print_verbose) printf("Creating image %s\n", screenshot_image_name); R2Image image(GLUTwindow_width, GLUTwindow_height, 3); image.Capture(); image.Write(screenshot_image_name); screenshot_image_name = NULL; } // Swap buffers glutSwapBuffers(); }