/*! \qmlmethod QtAudioEngine1::Sound::play(position, velocity, direction, gain, pitch) Creates a new SoundInstance and starts playing with specified \a position, \a velocity, \a direction, adjusted \a gain and \a pitch. */ void QDeclarativeSound::play(const QVector3D& position, const QVector3D& velocity, const QVector3D& direction, qreal gain, qreal pitch) { if (!m_complete) { qWarning() << "AudioEngine::play not ready!"; return; } QDeclarativeSoundInstance *instance = this->newInstance(true); if (!instance) return; instance->setPosition(position); instance->setVelocity(velocity); instance->setDirection(direction); instance->setGain(gain); instance->setPitch(pitch); instance->setConeInnerAngle(cone()->innerAngle()); instance->setConeOuterAngle(cone()->outerAngle()); instance->setConeOuterGain(cone()->outerGain()); instance->play(); #ifdef DEBUG_AUDIOENGINE qDebug() << "Sound[" << m_name << "] play (" << position << "," << velocity <<"," << direction << "," << gain << "," << pitch << ")triggered"; #endif }
/* * Draws a pine tree - cyclinder with two cones ontop of it */ void tree_Pine(float x, float y, float z, float c){ glPushMatrix(); glTranslatef(x,y,z); glScalef(TREE_SCALE_FACTOR,TREE_SCALE_FACTOR, TREE_SCALE_FACTOR); cyclinder(); glColor3f(0.0,c,0.0); cone(0.5); cone(0.35); glPopMatrix(); }
void scene() { floor(); float red[] = {1,0,0,1}; float yellow[] = {.8,.8,0,1}; float purple[] = {.4,0,.4,1}; glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); cone (.4,1.2, -2,3); glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, yellow); cone (.4,1.6, 2,-2); glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, purple); cone (.4,1.2, -2.4,-2.5); }
TEST_F(LidarObstacleTest, getLengthTest) { LidarObstacle long_wall({{-M_PI / 4, 1}, {-M_PI / 6, 20}, {M_PI / 4, 1}}); LidarObstacle cone({{0, 1}, {M_PI / 3, 1}}); EXPECT_DOUBLE_EQ(std::sqrt(2), long_wall.getLength()); EXPECT_DOUBLE_EQ(1, cone.getLength()); }
void createFurnishings() { glTranslatef(0, -height + 2 * wide / 8, - Dept+2 * Dept / 8); drawSphere(); glTranslatef(0, height - 2 * wide / 8, Dept - 2 * Dept / 8); cone(); }
void intersection(t_env *rt, t_vector ray, t_vector origin) { int i; rt->i2 = -1; i = 0; rt->t = 200000; rt->disk_cy = 0; rt->disk_s = 0; while (i < rt->nbobj) { rt->object[i].shadows = 0; if ((rt->object[i].name == SPHERE && sphere(ray, rt->object[i], &rt->t, rt->eye)) || (rt->object[i].name == PLANE && plane(ray, rt->object[i], &rt->t, rt->eye)) || (rt->object[i].name == CYLINDER && cylinder(ray, rt->object[i], &rt->t, rt->eye)) || ((rt->object[i].name == CONE || rt->object[i].name == HYPERBOL) && cone(ray, rt->object[i], &rt->t, rt->eye)) || intersection2(rt, ray, origin, i)) rt->i2 = i; i++; } }
void glschool_createDrawLists(BBox *bbox, GLuint *bboxList, GLuint *goalList, GLuint *fishList, int *fish_polys, int *box_polys, int wire) { int faces = 16; *box_polys = 0; *fish_polys = 0; *box_polys += glschool_createBBoxList(bbox, bboxList, wire); *box_polys = 0; *fish_polys = 0; *goalList = glGenLists(1); glNewList(*goalList, GL_COMPILE); glScalef (5, 5, 5); *box_polys += unit_sphere (10, 10, wire); glEndList(); *fishList = glGenLists(1); glNewList(*fishList, GL_COMPILE); *fish_polys += cone (0, 0, 0, 0, 0, 10, 2, 0, faces, True, (faces <= 3), /* cap */ wire); glTranslatef (0, 0, -0.3); glScalef (2, 2, 2); glRotatef (90, 1, 0, 0); if (faces > 3) *fish_polys += unit_sphere (faces, faces, wire); glEndList(); }
void myInit(void) { srand(time(NULL)); // Load shaders and use the resulting shader program GLuint program = InitShader("./tri.vert", "./tri.frag"); glUseProgram(program); cone(points, NumVertices); // Create a vertex array object GLuint vao; glGenVertexArrays(1, &vao); glBindVertexArray(vao); // Create and initalize a buffer object GLuint buffer; glGenBuffers(1, &buffer); glBindBuffer(GL_ARRAY_BUFFER, buffer); glBufferData(GL_ARRAY_BUFFER, sizeof(points), points, GL_STATIC_DRAW); // set up vertex array ( layout = 0 ) GLuint vPosition = glGetAttribLocation(program, "vPosition"); glEnableVertexAttribArray(vPosition); glVertexAttribPointer(vPosition, 4, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0)); theta = glGetUniformLocation(program, "theta"); glClearColor(1.0, 1.0, 1.0, 1.0); }
void UsdImagingConeAdapter::TrackVariability(UsdPrim const& prim, SdfPath const& cachePath, int requestedBits, int* dirtyBits, UsdImagingInstancerContext const* instancerContext) { BaseAdapter::TrackVariability( prim, cachePath, requestedBits, dirtyBits, instancerContext); // WARNING: This method is executed from multiple threads, the value cache // has been carefully pre-populated to avoid mutating the underlying // container during update. if (requestedBits & HdChangeTracker::DirtyPoints) { UsdGeomCone cone(prim); if (not _IsVarying(prim, UsdGeomTokens->radius, HdChangeTracker::DirtyPoints, UsdImagingTokens->usdVaryingPrimVar, dirtyBits, /*isInherited*/false)) { _IsVarying(prim, UsdGeomTokens->height, HdChangeTracker::DirtyPoints, UsdImagingTokens->usdVaryingPrimVar, dirtyBits, /*isInherited*/false); } } }
void draw_ear(void) { glPushMatrix(); // draw ear (left and right) : cone of dimension 4 x 5 x 4 glScalef(4.0, 5.0, 4.0); cone(); glPopMatrix(); }
bool SpotLight::Intersect(Intersection::Sphere &sphere) { if(angle < 1) angle = 1; else if(angle > 179) angle = 179; Cone cone(angle, range, forward, GetWorldPosition()); return cone.Intersection(sphere); }
void scene() { floor(); glPushAttrib(GL_ALL_ATTRIB_BITS); glEnable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); float red[] = {1, 0, 0}; float green[] = {0, 1, 0}; float blue[] = {0, 0, 1}; float black[] = {0, 0, 0}; cone( 3, 0, 3, red); cone(-3, 0, 3, green); cone(-3, 0,-3, blue); cone( 3, 0,-3, black); glPopAttrib(); }
/* * spike * ------ * Draw a spike * at (x, y, z) * radius r, height h, with 360/deg sides * rotated ox around the x axis * rotated oy around the y axis * rotated oz around the z axis */ void spike(double x, double y, double z, double r,double h,int deg, double ox,double oy,double oz) { glPushMatrix(); glRotated(oz,0,0,1); glRotated(oy,0,1,0); glRotated(ox,1,0,0); cone(x,y,z, r,h,deg); glPopMatrix(); }
void render() { sphere(); teapot(); cone(); torus(); tetrahedron(); }
void move_wall(t_game *p) { if (p->algo == 1) front(p); else if (p->algo == 2) cone(p); else if (p->algo == 3) turn_left(p); else if (p->algo == 4) turn_right(p); else if (p->algo == 5) reverse_cone(p); }
int main (void) { IloEnv env; int retval = -1; try { // Create the model. IloModel model(env); IloCplex cplex(env); IloObjective obj(env); IloNumVarArray vars(env); IloRangeArray rngs(env); IloIntArray cone(env); createmodel(model, obj, vars, rngs, cone); // Extract model. cplex.extract(model); // Solve the problem. If we cannot find an _optimal_ solution then // there is no point in checking the KKT conditions and we throw an // exception. cplex.setParam(IloCplex::Param::Barrier::QCPConvergeTol, CONVTOL); if ( !cplex.solve() || cplex.getStatus() != IloAlgorithm::Optimal ) throw string("Failed to solve problem to optimality"); // Test the KKT conditions on the solution. if ( !checkkkt (cplex, obj, vars, rngs, cone, TESTTOL) ) { env.error() << "Testing of KKT conditions failed." << endl; } else { env.out() << "Solution status: " << cplex.getStatus() << endl; env.out() << "KKT conditions are satisfied." << endl; retval = 0; } env.end(); } catch (IloException &e) { cerr << "IloException: " << e << endl; if (env.getImpl()) env.end(); ::abort(); } catch (string& e) { cerr << e << endl; if (env.getImpl()) env.end(); ::abort(); } return retval; }
double compute_object(t_ray ray, t_object object) { double len; len = 0; if (object.type == SPHERE) len = sphere(ray, object); else if (object.type == PLAN) len = plan(ray, object); else if (object.type == CYLINDER) len = cylinder(ray, object); else if (object.type == CONE) len = cone(ray, object); return (len); }
t_intersect calculate_intersection(t_pov *pov, t_coordinate *rayvector, t_object *object) { t_intersect intersect; if (my_strcmp(object->type, "sphere") == 0) intersect = sphere(*pov, *rayvector, object); if (my_strcmp(object->type, "plane") == 0) intersect = plane(*pov, *rayvector, object); if (my_strcmp(object->type, "cone") == 0) intersect = cone(*pov, *rayvector, object); if (my_strcmp(object->type, "cylinder") == 0) intersect = cylinder(*pov, *rayvector, object); return (intersect); }
void displayObject() { setMaterial(); setLighting(); setViewport(); setCamera(); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); kubus(); prisma(); teko(); bola(); cone(); donat(); glFlush(); }
int main() { double conicalIndenterWeight = 100; double conicalIndenterInitialSpeed = 100; double solidHalfSpaceDensity = 100; double solidHalfSpaceCoefficient = 100; double solidHalfSpaceFriction = 100; double solidHalfSpaceStrength = 100; Cone cone(solidHalfSpaceDensity, solidHalfSpaceCoefficient, solidHalfSpaceFriction, solidHalfSpaceStrength, conicalIndenterWeight, conicalIndenterInitialSpeed); return 0; }
/* filled cone */ static Bool myCone(float radius) { #if 0 GLUquadricObj *quadObj; if ((quadObj = gluNewQuadric()) == 0) return False; gluQuadricDrawStyle(quadObj, (GLenum) GLU_FILL); gluCylinder(quadObj, radius, 0, radius * 2, 8, 1); gluDeleteQuadric(quadObj); #else cone (0, 0, 0, 0, 0, radius * 2, radius, 0, 8, True, True, False); #endif return True; }
/*static*/ VtValue UsdImagingConeAdapter::GetMeshPoints(UsdPrim const& prim, UsdTimeCode time) { UsdGeomCone cone(prim); double radius = 1.0; double height = 2.0; TfToken axis = UsdGeomTokens->z; TF_VERIFY(cone.GetRadiusAttr().Get(&radius, time)); TF_VERIFY(cone.GetHeightAttr().Get(&height, time)); TF_VERIFY(cone.GetAxisAttr().Get(&axis, time)); // We could express radius and height via a // (potentially non-uniform) scaling transformation. return VtValue(_GenerateConeMeshPoints(float(radius), float(height), axis)); }
/** Simple cone using dimensions to be used to define cone composed of 1 single material @author Clement Helsens **/ static DD4hep::Geometry::Ref_t createSimpleCone(DD4hep::Geometry::LCDD& lcdd, xml_h e, DD4hep::Geometry::SensitiveDetector sensDet) { xml_det_t x_det = e; std::string name = x_det.nameStr(); DD4hep::Geometry::DetElement coneDet(name, x_det.id()); DD4hep::Geometry::Volume experimentalHall = lcdd.pickMotherVolume(coneDet); xml_comp_t coneDim(x_det.child(_U(dimensions))); DD4hep::Geometry::Cone cone(coneDim.dz(), coneDim.rmin1(), coneDim.rmax1(), coneDim.rmin2(), coneDim.rmax2()); DD4hep::Geometry::Volume coneVol(x_det.nameStr() + "_SimpleCone", cone, lcdd.material(coneDim.materialStr())); if (x_det.isSensitive()) { DD4hep::XML::Dimension sdType(x_det.child(_U(sensitive))); coneVol.setSensitiveDetector(sensDet); sensDet.setType(sdType.typeStr()); } DD4hep::Geometry::PlacedVolume conePhys; double zoff = coneDim.z_offset(); if (fabs(zoff) > 0.000000000001) { double reflectionAngle = 0.; if (coneDim.hasAttr(_Unicode(reflect))) { if (coneDim.reflect()) { reflectionAngle = M_PI; } } DD4hep::Geometry::Position trans(0., 0., zoff); conePhys = experimentalHall.placeVolume(coneVol, DD4hep::Geometry::Transform3D(DD4hep::Geometry::RotationX(reflectionAngle), trans)); } else conePhys = experimentalHall.placeVolume(coneVol); conePhys.addPhysVolID("system", x_det.id()); coneDet.setPlacement(conePhys); coneDet.setVisAttributes(lcdd, x_det.visStr(), coneVol); return coneDet; }
void createDrawLists(BBox *bbox, GLuint *bboxList, GLuint *goalList, GLuint *fishList, Bool wire) { createBBoxList(bbox, bboxList, wire); *goalList = glGenLists(1); glNewList(*goalList, GL_COMPILE); glScalef(10.0, 10.0, 10.0); unit_sphere(10, 10, wire); glEndList(); *fishList = glGenLists(1); glNewList(*fishList, GL_COMPILE); glScalef(2.0, 2.0, 2.0); unit_sphere(10, 10, wire); cone(0, 0, 0, 0, 0, 5, 1, 0, 10, True, False, wire); glEndList(); }
glm::mat4 Hand::initialiseJoint( glm::mat4 start, double* xRot, double* zRot, double diameter, double length, double coneRatio) { // Store current rotation and translation glm::mat4 current, c, r, s, t; // CYLINDER s = glm::scale(glm::mat4(1.0f), glm::vec3(diameter, length, diameter)); // Shift because cylinder doesn't start at origin t = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, length/2, 0.0f)); // Basic constraints //if (*zRot < 0) *zRot = 0; //else if (*zRot > M_PI/2) *zRot = M_PI/2; //if (*xRot > M_PI/8) *xRot = M_PI/8; //else if (*xRot < -M_PI/8) *xRot = -M_PI/8; glm::quat o(glm::vec3(*zRot, 0.0f, *xRot)); glm::gtc::quaternion::normalize(o); r = glm::toMat4(o); c = cone(coneRatio); current = start * r; cylinderWVPs.push_back(current * t * s * c); // SPHERE s = glm::scale(glm::mat4(1.0f), glm::vec3( coneRatio * diameter, coneRatio * diameter, coneRatio * diameter)); t = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, length, 0.0f)); current = current * t; sphereWVPs.push_back(current * s); return current; }
CRhinoCommand::result CCommandSampleCone::RunCommand( const CRhinoCommandContext& context ) { ON_Plane plane = ON_xy_plane; double height = 10.0; double radius = 5.0; BOOL bCapBottom = FALSE; ON_Cone cone( plane, height, radius ); if( cone.IsValid() ) { ON_Brep* cone_brep = ON_BrepCone( cone, bCapBottom ); if( cone_brep ) { CRhinoBrepObject* cone_object = new CRhinoBrepObject(); cone_object->SetBrep( cone_brep ); context.m_doc.AddObject( cone_object ); context.m_doc.Redraw(); } } return CRhinoCommand::success; }
void iscrtaj(void) { double a = 8.0; // duljina stranice kocke double d = 0.5; // odmak od osi glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3d(1.0, 1.0, 0.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(32.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); glRotated(kut, 0.0, 0.0, 1.0); glRotated(kut, 0.0, 1.0, 0.0); glRotated(kut, 1.0, 0.0, 0.0); osi(20.0); glTranslated(d, d, d); cone(2.5, 5.0, 20); glutSwapBuffers(); } // iscrtaj
// setter int define::update(string& data) { const char* header = getHeader().c_str(); // get the text vector<string> lines = BZWParser::getSectionsByHeader(header, data.c_str(), "enddef"); if(lines[0] == BZW_NOT_FOUND) return 0; if(lines.size() > 1) { printf("define::update(): Error! Defined \"define\" %d times!\n", (int)lines.size()); return 0; } // get the name vector<string> names = BZWParser::getValuesByKey("define", header, lines[0].c_str()); if(!hasOnlyOne(names, header)) return 0; // get the data string::size_type sectionStart = lines[0].find("\n") + 1; string::size_type sectionLength = lines[0].find( "enddef", sectionStart ) - sectionStart; lines[0] = lines[0].substr( sectionStart, sectionLength ); const char* defineData = lines[0].c_str(); // get the chunks vector<string> chunks = BZWParser::getSections( defineData ); // get all the supported objects from the lines, but don't commit them yet // arc vector<string> arcs = BZWParser::findSections("arc", chunks); vector<arc> arcData; if(arcs[0] != BZW_NOT_FOUND) { for(vector<string>::iterator i = arcs.begin(); i != arcs.end(); i++) { arc tmp = arc(); if(!tmp.update(*i)) return 0; arcData.push_back( tmp ); } } // base vector<string> bases = BZWParser::findSections("base", chunks); vector<base> baseData; if(bases[0] != BZW_NOT_FOUND) { for(vector<string>::iterator i = bases.begin(); i != bases.end(); i++) { base tmp = base(); if(!tmp.update(*i)) return 0; baseData.push_back( tmp ); } } // box vector<string> boxes = BZWParser::findSections("box", chunks); vector<box> boxData; if(boxes[0] != BZW_NOT_FOUND) { for(vector<string>::iterator i = boxes.begin(); i != boxes.end(); i++) { box tmp = box(); if(!tmp.update(*i)) return 0; boxData.push_back( tmp ); } } // cone vector<string> cones = BZWParser::findSections("cone", chunks); vector<cone> coneData; if(cones[0] != BZW_NOT_FOUND) { for(vector<string>::iterator i = cones.begin(); i != cones.end(); i++) { cone tmp = cone(); if(!tmp.update(*i)) return 0; coneData.push_back( tmp ); } } // group vector<string> groups = BZWParser::findSections("group", chunks); vector<group> groupData; if(groups[0] != BZW_NOT_FOUND) { for(vector<string>::iterator i = groups.begin(); i != groups.end(); i++) { group tmp = group(); if(!tmp.update(*i)) return 0; groupData.push_back( tmp ); } } // mesh vector<string> meshes = BZWParser::findSections("mesh", chunks); vector<mesh> meshData; if(meshes[0] != BZW_NOT_FOUND) { for(vector<string>::iterator i = meshes.begin(); i != meshes.end(); i++) { mesh tmp = mesh(); if(!tmp.update(*i)) return 0; meshData.push_back( tmp ); } } // meshbox vector<string> meshboxes = BZWParser::findSections("meshbox", chunks); vector<meshbox> meshboxData; if(meshboxes[0] != BZW_NOT_FOUND) { for(vector<string>::iterator i = meshboxes.begin(); i != meshboxes.end(); i++) { meshbox tmp = meshbox(); if(!tmp.update(*i)) return 0; meshboxData.push_back( tmp ); } } // meshpyr vector<string> meshpyrs = BZWParser::findSections("meshpyr", chunks); vector<meshpyr> meshpyrData; if(meshpyrs[0] != BZW_NOT_FOUND) { for(vector<string>::iterator i = meshpyrs.begin(); i != meshpyrs.end(); i++) { meshpyr tmp = meshpyr(); if(!tmp.update(*i)) return 0; meshpyrData.push_back( tmp ); } } // pyramid vector<string> pyramids = BZWParser::findSections("pyramid", chunks); vector<pyramid> pyramidData; if(pyramids[0] != BZW_NOT_FOUND) { for(vector<string>::iterator i = pyramids.begin(); i != pyramids.end(); i++) { pyramid tmp = pyramid(); if(!tmp.update(*i)) return 0; pyramidData.push_back( tmp ); } } // sphere vector<string> spheres = BZWParser::findSections("sphere", chunks); vector<sphere> sphereData; if(spheres[0] != BZW_NOT_FOUND) { for(vector<string>::iterator i = spheres.begin(); i != spheres.end(); i++) { sphere tmp = sphere(); if(!tmp.update(*i)) return 0; sphereData.push_back( tmp ); } } // teleporter vector<string> teleporters = BZWParser::findSections("teleporter", chunks); vector<teleporter> teleporterData; if(teleporters[0] != BZW_NOT_FOUND) { for(vector<string>::iterator i = teleporters.begin(); i != teleporters.end(); i++) { teleporter tmp = teleporter(); if(!tmp.update(*i)) return 0; teleporterData.push_back( tmp ); } } // tetra vector<string> tetras = BZWParser::findSections("tetra", chunks); vector<tetra> tetraData; if(tetras[0] != BZW_NOT_FOUND) { for(vector<string>::iterator i = tetras.begin(); i != tetras.end(); i++) { tetra tmp = tetra(); if(!tmp.update(*i)) return 0; tetraData.push_back( tmp ); } } // base-class update (must be done BEFORE commiting new objects) if(!DataEntry::update(data)) { return 0; } // commit name name = names[0]; // free previous objects objects.clear(); // commit arcs if(arcData.size() > 0) { for(vector<arc>::iterator i = arcData.begin(); i != arcData.end(); i++) { objects.push_back( new arc(*i) ); } } // commit bases if(baseData.size() > 0) { for(vector<base>::iterator i = baseData.begin(); i != baseData.end(); i++) { objects.push_back( new base(*i) ); } } // commit boxes if(boxData.size() > 0) { for(vector<box>::iterator i = boxData.begin(); i != boxData.end(); i++) { objects.push_back( new box(*i) ); } } // commit cones if(coneData.size() > 0) { for(vector<cone>::iterator i = coneData.begin(); i != coneData.end(); i++) { objects.push_back( new cone(*i) ); } } // commit groups if(groupData.size() > 0) { for(vector<group>::iterator i = groupData.begin(); i != groupData.end(); i++) { objects.push_back( new group(*i) ); } } // commit meshes if(meshData.size() > 0) { for(vector<mesh>::iterator i = meshData.begin(); i != meshData.end(); i++) { objects.push_back( new mesh(*i) ); } } // commit meshboxes if(meshboxData.size() > 0) { for(vector<meshbox>::iterator i = meshboxData.begin(); i != meshboxData.end(); i++) { objects.push_back( new meshbox(*i) ); } } // commit meshpyrs if(meshpyrData.size() > 0) { for(vector<meshpyr>::iterator i = meshpyrData.begin(); i != meshpyrData.end(); i++) { objects.push_back( new meshpyr(*i) ); } } // commit pyramids if(pyramidData.size() > 0) { for(vector<pyramid>::iterator i = pyramidData.begin(); i != pyramidData.end(); i++) { objects.push_back( new pyramid(*i) ); } } // commit spheres if(sphereData.size() > 0) { for(vector<sphere>::iterator i = sphereData.begin(); i != sphereData.end(); i++) { objects.push_back( new sphere(*i) ); } } // commit teleporters if(teleporterData.size() > 0) { for(vector<teleporter>::iterator i = teleporterData.begin(); i != teleporterData.end(); i++) { objects.push_back( new teleporter(*i) ); } } // commit tetras if(tetraData.size() > 0) { for(vector<tetra>::iterator i = tetraData.begin(); i != tetraData.end(); i++) { objects.push_back( new tetra(*i) ); } } return 1; }
ENTRYPOINT void init_ball (ModeInfo *mi) { ball_configuration *bp; int wire = MI_IS_WIREFRAME(mi); MI_INIT (mi, bps); bp = &bps[MI_SCREEN(mi)]; bp->glx_context = init_GL(mi); reshape_ball (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); if (!wire) { GLfloat pos[4] = {1.0, 1.0, 1.0, 0.0}; GLfloat amb[4] = {0.0, 0.0, 0.0, 1.0}; GLfloat dif[4] = {1.0, 1.0, 1.0, 1.0}; GLfloat spc[4] = {0.0, 1.0, 1.0, 1.0}; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glLightfv(GL_LIGHT0, GL_POSITION, pos); glLightfv(GL_LIGHT0, GL_AMBIENT, amb); glLightfv(GL_LIGHT0, GL_DIFFUSE, dif); glLightfv(GL_LIGHT0, GL_SPECULAR, spc); } { double spin_speed = 10.0; double wander_speed = 0.12; double spin_accel = 2.0; bp->rot = make_rotator (do_spin ? spin_speed : 0, do_spin ? spin_speed : 0, do_spin ? spin_speed : 0, spin_accel, do_wander ? wander_speed : 0, True); bp->trackball = gltrackball_init (True); } bp->ncolors = 128; bp->colors = (XColor *) calloc(bp->ncolors, sizeof(XColor)); make_smooth_colormap (0, 0, 0, bp->colors, &bp->ncolors, False, 0, False); bp->spikes = (int *) calloc(MI_COUNT(mi), sizeof(*bp->spikes) * 2); bp->ball_list = glGenLists (1); bp->spike_list = glGenLists (1); glNewList (bp->ball_list, GL_COMPILE); unit_sphere (SPHERE_STACKS, SPHERE_SLICES, wire); glEndList (); glNewList (bp->spike_list, GL_COMPILE); cone (0, 0, 0, 0, 1, 0, 1, 0, SPIKE_FACES, SMOOTH_SPIKES, False, wire); glEndList (); randomize_spikes (mi); }
void buildFakeAngTree(const Char_t* outtag, const Float_t timereso, // ns const UInt_t simevts=1, const Float_t thetaOpt=400, // deg const Float_t phiOpt=400, // deg const Float_t coneOpt=400, // deg const UInt_t rseed=23192, const Float_t norm=100.0, // mV const Float_t noise=20.0, // mV const Char_t* outdir="/data/users/cjreed/work/simEvts", const Char_t* infn="/w2/arianna/jtatar/nt.sigtemps.root", const Char_t* geofn="/data/users/cjreed/work/" "BounceStudy/Stn10/" "CampSiteGeometry.root") { // if any of the angles (thetaOpt, phiOpt, coneOpt) > 360, a random // value will be used instead // // expect angles in the Templates tree to be in degrees // // expect the waveforms in the Templates tree to have amplitude 1 TRandom3 rnd(rseed); geof = TFile::Open(geofn); gg = dynamic_cast<TGeoManager*>(geof->Get("CampSite2013")); site = dynamic_cast<const TSnGeoStnSite*>(gg->GetTopVolume()); TVector3 pos[NSnConstants::kNchans], nvec[NSnConstants::kNchans]; for (UChar_t ch=0; ch<NSnConstants::kNchans; ++ch) { site->SetLPDAPosition(ch, pos[ch]); site->SetLPDANormalVec(ch, nvec[ch]); Printf("pos ch%d:",ch); pos[ch].Print(); Printf("normal ch%d:",ch); nvec[ch].Print(); } TArrayD zeros(6); inf = TFile::Open(infn); nnt = dynamic_cast<TTree*>(inf->Get("Templates")); TString infns(infn); TString indir; Int_t fl(0); if (infns.Contains('/')) { fl = infns.Last('/') + 1; indir = infns(0, fl-1); } TString plaininfn = infns(fl, infns.Length()-fl); TString outfn = Form("%s/FakeEvts.%s.%s", outdir, outtag, plaininfn.Data()); outf = TFile::Open(outfn.Data(),"recreate"); outf->cd(); TParameter<Float_t> trp("TimeResolution", timereso); trp.Write(); TParameter<Float_t> nmp("Normalization", norm); nmp.Write(); TParameter<Float_t> nop("NoiseRMS", noise); nop.Write(); TParameter<UInt_t> rsp("RandomSeed", rseed); rsp.Write(); TSnCalWvData* wave = new TSnCalWvData; Float_t eang(0), hang(0), hpf(0), limiter(0), coneang(0); Bool_t bice(kFALSE); nnt->SetBranchAddress("wave.",&wave); nnt->SetBranchAddress("EAng",&eang); nnt->SetBranchAddress("HAng",&hang); nnt->SetBranchAddress("hpf",&hpf); nnt->SetBranchAddress("limiter",&limiter); nnt->SetBranchAddress("coneAng",&coneang); nnt->SetBranchAddress("bIce",&bice); // to look up waveform for EAng, HAng nnt->BuildIndex("EAng + (1000*HAng)","coneAng"); // find the max angles Printf("finding allowed angles..."); std::set<Float_t> Eangs, Hangs, Cangs; const Long64_t nnents = nnt->GetEntries(); for (Long64_t i=0; i<nnents; ++i) { nnt->GetEntry(i); Eangs.insert(eang); Hangs.insert(hang); Cangs.insert(coneang); } #ifdef DEBUG std::set<Float_t>::const_iterator ang, end = Eangs.end(); Printf("EAngs:"); for (ang=Eangs.begin(); ang!=end; ++ang) { Printf("%g",*ang); } Printf("HAngs:"); for (ang=Hangs.begin(), end=Hangs.end(); ang!=end; ++ang) { Printf("%g",*ang); } Printf("ConeAngs:"); for (ang=Cangs.begin(), end=Cangs.end(); ang!=end; ++ang) { Printf("%g",*ang); } #endif Float_t theta(0), phi(0), cone(0); Float_t EAng[NSnConstants::kNchans], HAng[NSnConstants::kNchans]; Float_t CAng(0); TSnCalWvData* evdat = new TSnCalWvData; TSnEventMetadata* meta = new TSnEventMetadata; TSnEventHeader* hdr = new TSnEventHeader; //ot = nnt->CloneTree(0); //ot->SetName("SimTemplEvts"); ot = new TTree("SimTemplEvts","simulated events from templates",1); ot->SetDirectory(outf); ot->Branch("EventMetadata.",&meta); ot->Branch("EventHeader.",&hdr); ot->Branch("EAng",&(EAng[0]),Form("EAng[%hhu]/F",NSnConstants::kNchans)); ot->Branch("HAng",&(HAng[0]),Form("HAng[%hhu]/F",NSnConstants::kNchans)); ot->Branch("CAng",&CAng,"CAng/F"); ot->Branch("theta",&theta,"theta/F"); ot->Branch("phi",&phi,"phi/F"); ot->Branch("NuData.",&evdat); // some useful aliases TString an; for (UChar_t ch=0; ch<NSnConstants::kNchans; ++ch) { // to use as a cut for a particular channel: an = Form("Ch%d",ch); ot->SetAlias(an.Data(), Form("(Iteration$>=(%hhu*%hhu)) && (Iteration$<(%hhu*%hhu))", NSnConstants::kNsamps, ch, NSnConstants::kNsamps, static_cast<UChar_t>(ch+1))); // to use as a variable showing the sample number [0,127] for any chan an = Form("SmpCh%d",ch); ot->SetAlias(an.Data(), Form("Iteration$-%u", static_cast<UInt_t>(ch) *static_cast<UInt_t>(NSnConstants::kNsamps))); // e.g. Draw("RawData.fData:SmpCh2","EventHeader.fNum==21 && Ch2","l") } Printf("generating events..."); TStopwatch timer; timer.Start(); for (UInt_t i=0; i<simevts; ++i) { if ( (i%1000)==0 ) { fprintf(stderr,"Processing %u/%u ... \r",i,simevts); } // choose angles theta = (thetaOpt>360.) ? TMath::ACos( rnd.Uniform(-1.0, 0.0) ) : thetaOpt * TMath::DegToRad(); phi = (phiOpt>360.) ? rnd.Uniform(0.0, TMath::TwoPi()) : phiOpt * TMath::DegToRad(); cone = (coneOpt>360.) ? rnd.Uniform(*(Cangs.begin()), *(Cangs.rbegin())) : coneOpt; // leave this one in degrees (as in the tree) CAng = findNearestAllowedAngle(Cangs, cone); #ifdef DEBUG Printf("--- theta=%g, phi=%g, cone=%g", theta*TMath::RadToDeg(), phi*TMath::RadToDeg(), cone); #endif // calculate channel shifts TArrayD pwdt = NSnChanCorl::GetPlaneWaveOffsets(theta, phi, zeros, pos, kNgTopFirn); TVector3 dir; dir.SetMagThetaPhi(1.0, theta, phi); #ifdef DEBUG TObjArray graphs; graphs.SetOwner(kTRUE); TCanvas* c1 = new TCanvas("c1","c1",800,700); c1->Divide(2,2); #endif for (UChar_t ch=0; ch<NSnConstants::kNchans; ++ch) { // look up the EAng, fhang for this antenna Float_t feang(0), fhang(0); findEangHang(nvec[ch], dir, feang, fhang); feang = TMath::Abs(TVector2::Phi_mpi_pi(feang)); fhang = TMath::Abs(TVector2::Phi_mpi_pi(fhang)); feang *= TMath::RadToDeg(); fhang *= TMath::RadToDeg(); // find closest allowed angle EAng[ch] = findNearestAllowedAngle(Eangs, feang); HAng[ch] = findNearestAllowedAngle(Hangs, fhang); const Long64_t ni = nnt->GetEntryNumberWithIndex(EAng[ch] + (1000*HAng[ch]), CAng); #ifdef DEBUG Printf("EAng=%g (%g), HAng=%g (%g), CAng=%g, ni=%lld", EAng[ch],feang,HAng[ch],fhang,CAng,ni); #endif if (ni>-1) { nnt->GetEntry(ni); #ifdef DEBUG c1->cd(ch+1); TGraph* och = wave->NewGraphForChan(0, kTRUE); const Int_t ochnp = och->GetN(); Double_t* ochy = och->GetY(); for (Int_t k=0; k<ochnp; ++k, ++ochy) { *ochy *= norm; } graphs.Add(och); och->SetLineColor(kBlack); och->SetMarkerColor(kBlack); och->SetMarkerStyle(7); och->Draw("apl"); #endif // first calculate the shift between chans due to the angle // ch0 is always unshifted; other chans shifted w.r.t. ch0 // jitter the shift by the specified timing resolution const Double_t shift = rnd.Gaus( (ch==0) ? 0.0 : -pwdt.At( TSnRecoChanOffsets::IndexFor(ch, 0) ), timereso); // get a graph of the waveform // data only in channel 0 of the template TGraph* gch = wave->NewGraphForChan(0, kTRUE); // "fit" the graph with an spline interpolation TSpline3* gsp = new TSpline3("stmp", gch); // evaluate the spline at the new sample positions // (shifted, but NOT wrapped) // and save that into the event data waveform Float_t* d = evdat->GetData(ch); const Float_t tstep = 1.0 / NSnConstants::kSampRate; const Float_t tlast = static_cast<Float_t>(NSnConstants::kNsamps-1) / NSnConstants::kSampRate; Float_t xloc = shift; for (UChar_t s=0; s<NSnConstants::kNsamps; ++s, ++d, xloc+=tstep) { if ( (xloc<0.0) || (xloc>=tlast) ) { *d = 0.0; } else { *d = gsp->Eval( xloc ); } } #ifdef DEBUG Printf("ch%hhu: shift=%g, dt=%g", ch, shift, (ch==0) ? 0.0 : pwdt.At( TSnRecoChanOffsets::IndexFor(ch, 0) )); TGraph* fch = evdat->NewGraphForChan(ch, kTRUE); Double_t* y = gch->GetY(); Double_t* fy = fch->GetY(); for (UChar_t s=0; s<NSnConstants::kNsamps; ++s, ++y, ++fy) { *y *= norm; *fy *= norm; } gch->SetLineColor(kRed+1); gch->SetMarkerColor(kRed+1); gch->SetMarkerStyle(7); gch->Draw("pl"); delete gsp; gsp = new TSpline3("stmp",gch); gsp->SetLineColor(kAzure-6); gsp->SetMarkerColor(kAzure-6); gsp->SetMarkerStyle(7); gsp->Draw("pl same"); graphs.Add(fch); fch->SetLineColor(kOrange+7); fch->SetMarkerColor(kOrange+7); fch->SetMarkerStyle(7); fch->Draw("pl"); #endif d = evdat->GetData(ch); // finally add noise to the waveform for (UChar_t s=0; s<NSnConstants::kNsamps; ++s, ++d) { *d = rnd.Gaus( (*d) * norm, noise ); } #ifdef DEBUG TGraph* nch = evdat->NewGraphForChan(ch, kTRUE); graphs.Add(nch); nch->SetLineColor(kGreen+2); nch->SetMarkerColor(kGreen+2); nch->SetMarkerStyle(7); nch->Draw("pl"); #endif // cleanup #ifdef DEBUG graphs.Add(gch); graphs.Add(gsp); #else delete gch; delete gsp; #endif } } // end channel loop #ifdef DEBUG TObject* o(0); while ( (o=c1->WaitPrimitive())!=0 ) { gSystem->ProcessEvents(); } delete c1; #endif // save this event ot->Fill(); } // end event loop fprintf(stderr,"\n"); timer.Stop(); Printf("Finished generating events in:"); timer.Print(); outf->Write(); Printf("Wrote [%s]",outf->GetName()); delete outf; outf=0; // close file }