circle::circle(pos p, double radius, double radiussize, gradient grad, int bt) : shape(bt), gradient_(grad) { set_x(p.get_x()); set_y(p.get_y()); set_z(p.get_z()); set_radius(radius); set_radiussize(radiussize); }
/** * @brief Stops the movement. */ void CircleMovement::stop() { previous_radius = current_radius; set_radius(0); if (loop_delay != 0) { restart_date = System::now() + loop_delay; } recompute_position(); }
/** * @brief Sets the radius to be updated immediately or gradually towards its wanted value. * * Use set_radius() to specify the wanted value. * * @param radius_speed speed of the radius variation (number of pixels per second), * or 0 to update it immediately */ void CircleMovement::set_radius_speed(int radius_speed) { Debug::check_assertion(radius_speed >= 0, StringConcat() << "Invalid radius speed: " << radius_speed); if (radius_speed == 0) { this->radius_change_delay = 0; } else { this->radius_change_delay = 1000 / radius_speed; } set_radius(wanted_radius); }
/** * \brief Sets the radius to be updated immediately or gradually towards its wanted value. * * Use set_radius() to specify the wanted value. * * \param radius_speed speed of the radius variation (number of pixels per second), * or 0 to update it immediately */ void CircleMovement::set_radius_speed(int radius_speed) { if (radius_speed < 0) { std::ostringstream oss; oss << "Invalid radius speed: " << radius_speed; Debug::die(oss.str()); } if (radius_speed == 0) { this->radius_change_delay = 0; } else { this->radius_change_delay = 1000 / radius_speed; } set_radius(wanted_radius); }
SphereShape::SphereShape() : Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_SPHERE)) { set_radius(1.0); }
/** * Construct a planet from its common name (e.g. VENUS) * * \param[in] name a string describing a planet */ jpl_lp::jpl_lp(const std::string& name) : ref_mjd2000(epoch(2451545.0,epoch::JD).mjd2000()) { std::map<std::string, int> mapped_planets; mapped_planets["mercury"] = 1; mapped_planets["venus"] = 2; mapped_planets["earth"] = 3; mapped_planets["mars"] = 4; mapped_planets["jupiter"] = 5; mapped_planets["saturn"] = 6; mapped_planets["uranus"] = 7; mapped_planets["neptune"] = 8; mapped_planets["pluto"] = 9; double mu_central_body; double mu_self; double radius; double safe_radius; std::string lower_case_name = name; boost::algorithm::to_lower(lower_case_name); switch ( mapped_planets[lower_case_name] ) { case (1): { std::copy(mercury_el,mercury_el+6,&jpl_elements[0]); std::copy(mercury_el_dot,mercury_el_dot+6,&jpl_elements_dot[0]); radius = 2440000.; safe_radius = 1.1; mu_self = 22032e9; mu_central_body = ASTRO_MU_SUN; } break; case (2): { std::copy(venus_el,venus_el+6,&jpl_elements[0]); std::copy(venus_el_dot,venus_el_dot+6,&jpl_elements_dot[0]); radius = 6052000.; safe_radius = 1.1; mu_self = 324859e9; mu_central_body = ASTRO_MU_SUN; } break; case (3): { std::copy(earth_moon_el,earth_moon_el+6,&jpl_elements[0]); std::copy(earth_moon_el_dot,earth_moon_el_dot+6,&jpl_elements_dot[0]); radius = 6378000.; safe_radius = 1.1; mu_self = 398600.4418e9; mu_central_body = ASTRO_MU_SUN; } break; case (4): { std::copy(mars_el,mars_el+6,&jpl_elements[0]); std::copy(mars_el_dot,mars_el_dot+6,&jpl_elements_dot[0]); radius = 3397000.; safe_radius = 1.1; mu_self = 42828e9; mu_central_body = ASTRO_MU_SUN; } break; case (5): { std::copy(jupiter_el,jupiter_el+6,&jpl_elements[0]); std::copy(jupiter_el_dot,jupiter_el_dot+6,&jpl_elements_dot[0]); radius = 71492000.; safe_radius = 9.; mu_self = 126686534e9; mu_central_body = ASTRO_MU_SUN; } break; case (6): { std::copy(saturn_el,saturn_el+6,&jpl_elements[0]); std::copy(saturn_el_dot,saturn_el_dot+6,&jpl_elements_dot[0]); radius = 60330000.; safe_radius = 1.1; mu_self = 37931187e9; mu_central_body = ASTRO_MU_SUN; } break; case (7): { std::copy(uranus_el,uranus_el+6,&jpl_elements[0]); std::copy(uranus_el_dot,uranus_el_dot+6,&jpl_elements_dot[0]); radius = 25362000.; safe_radius = 1.1; mu_self = 5793939e9; mu_central_body = ASTRO_MU_SUN; } break; case (8): { std::copy(neptune_el,neptune_el+6,&jpl_elements[0]); std::copy(neptune_el_dot,neptune_el_dot+6,&jpl_elements_dot[0]); radius = 24622000.; safe_radius = 1.1; mu_self = 6836529e9; mu_central_body = ASTRO_MU_SUN; } break; case (9): { std::copy(pluto_el,pluto_el+6,&jpl_elements[0]); std::copy(pluto_el_dot,pluto_el_dot+6,&jpl_elements_dot[0]); radius = 1153000.; safe_radius = 1.1; mu_self = 871e9; mu_central_body = ASTRO_MU_SUN; } break; default : { throw_value_error(std::string("unknown planet name: ") + name); } } set_mu_central_body(mu_central_body); set_mu_self(mu_self); set_radius(radius); set_safe_radius(safe_radius); set_name(lower_case_name); }
TRing::TRing(double radius, double hole_radius) { set_radius(radius, hole_radius); }
/** * @brief Updates the movement. */ void CircleMovement::update() { Movement::update(); if (center_entity != NULL && center_entity->is_being_removed()) { set_center(Rectangle( center_entity->get_x() + center_point.get_x(), center_entity->get_y() + center_point.get_y())); } if (is_suspended()) { return; } bool update_needed = false; uint32_t now = System::now(); // maybe it is time to stop or to restart if (current_radius != 0 && duration != 0 && now >= end_movement_date && wanted_radius != 0) { stop(); } else if (current_radius == 0 && loop_delay != 0 && now >= restart_date && wanted_radius == 0) { set_radius(previous_radius); start(); } // update the angle if (is_started()) { while (now >= next_angle_change_date) { current_angle += angle_increment; current_angle = (360 + current_angle) % 360; if (current_angle == initial_angle) { nb_rotations++; if (nb_rotations == max_rotations) { stop(); } } next_angle_change_date += angle_change_delay; update_needed = true; } } // update the radius while (current_radius != wanted_radius && now >= next_radius_change_date) { current_radius += radius_increment; next_radius_change_date += radius_change_delay; update_needed = true; } // the center may have moved if (center_entity != NULL) { update_needed = true; } if (update_needed) { recompute_position(); } }
Ellipse::Ellipse(double x_radius, double y_radius) { set_radius(x_radius, y_radius); }
bullet() { set_radius(5.f); }
enemy1(const resource_type &h): enemy(h) { set_radius(15.f); set_size(paint::size(30, 30)); time = std::chrono::system_clock::now(); }
void Cconfig::create_random() { int Npart_flow,Npart_wall_bottom,Npart_wall_top; cout<<endl<<"Attempt to create a random configuration of grains with no overlaping"<<endl<<endl; //System size get_secure("Enter the size of the system","SIZE_CELL",cell.L); //Kind of boundary // get_secure("Enter the kind of boundary you want along the y direction", "PERIODIC_SHEAR","WALL_INCLINED","WALL_SHEAR",cell.boundary); cell.boundary = BOUNDARY; // cout<<BOUNDARY<<endl; Npart_wall_bottom=0; Npart_wall_top=0; if(cell.boundary=="PERIODIC_SHEAR") { Npart_wall_bottom=0; Npart_wall_top=0; } if(cell.boundary=="WALL_INCLINED") { get_secure("Enter the number of grains of the bottom wall, including the plane (it counts as a grain)", "NPART_WALL_BOTTOM",Npart_wall_bottom); Npart_wall_top=0; if(Npart_wall_bottom<1){serror="The number of grains on the bottom wall must be >=1";STOP("cdinit.cpp", "create_random()",serror);} } if(cell.boundary=="WALL_SHEAR") { get_secure("Enter the number of grains of the bottom wall (>=1), including the plan (it counts as one grain)", "NPART_WALL_BOTTOM",Npart_wall_bottom); get_secure("Enter the number of grains of the top wall (>=1), including the plan (it counts as one grain)", "NPART_WALL_TOP",Npart_wall_top); if(Npart_wall_bottom<1 || Npart_wall_top<1){serror="The number of grains on the wall must be >=1";STOP("cdinit.cpp", "create_random()",serror);} } get_secure("Enter the number of compositions", "COMPOSITION", parameter.COMPOSITION); if(parameter.COMPOSITION<1) parameter.COMPOSITION=1; std::vector <double> radius; double packing; for(int i=0;i<parameter.COMPOSITION;i++){ get_secure("Enter the type of grain size distribution", "FRACTAL", "UNIFORM","VOLUME", parameter.GSD); get_secure("Enter the minimum diameter", "DMIN", parameter.Dmin); get_secure("Enter the minimum diameter", "DMAX", parameter.Dmax); if(parameter.GSD=="UNIFORM") get_secure("Enter the number of flowing grains (do not include the wall-grains)","NPART_FLOW",Npart_flow); if(parameter.GSD=="VOLUME") get_secure("Enter the number of flowing grains (do not include the wall-grains)","NPART_FLOW",Npart_flow); if(parameter.GSD=="FRACTAL") { get_secure("Enter the fractal dimention of the grain size distribution","FRACTAL_DIM", parameter.fractal_dim); get_secure("Enter the solid fraction wanted","SOLID_FRACTION", cell.solid_fraction); } srand( (unsigned int) time(NULL));//Init of random cout<<endl<<"Start the random setting of grains"<<endl; set_wall_grain(Npart_wall_bottom, Npart_wall_top); //set the grain of the wall and the planes (if there is any wall) std::vector <double> radius_tmp; set_radius(radius_tmp, Npart_flow); radius.insert(radius.end(),radius_tmp.begin(),radius_tmp.end()); } cout<<"Number of flowing grains\t"<<radius.size()<<endl; get_secure("Enter the initial packing factor", "PACKING", packing); if(packing<0 || packing>=1) { cout<<"This is not a realistic value for the initial packing factor! Setting to 0.5."<<endl; packing=0.5; } cout<<"A high initial packing factor may result in residual stresses after the packing stage."<<endl; // adjusting cell.L.x[1] for initial packing: fix box size, and expansion of grains. double volume=0.0; for(int ip=0;ip<radius.size();ip++) volume += pow(radius[ip],3.0); cell.L.x[2] = volume *4.0*PI/3.0 / packing /(cell.L.x[0]*cell.L.x[1]); cout<<"Adjusted cell depth for the initial packing\t"<<cell.L.x[2]<<endl; set_random_grain(Npart_flow, radius); for(int ip=0;ip<P.size();ip++)//example of how to initiate things, mass is to be initiated here, it won't be change after { double RHO; parameter.RHO = 1.0; // RHO = 6./PI; //mass 1 for diameter 1, at temperature 20 C (may change with thermal expansion) RHO = parameter.RHO; // default density is 1.0, may be changed during EVOLVE stage. if(P[ip].AM_I_BOUNDARY==0)//flowing particle { P[ip].m = 4./3. * PI * pow(P[ip].R_scale,3)*RHO; P[ip].T = 20; } if(P[ip].AM_I_BOUNDARY==-1 ||P[ip].AM_I_BOUNDARY==-2 )//bottom walls { P[ip].m = 0; //don't care the mass P[ip].T = 20; //can be change as wish } if(P[ip].AM_I_BOUNDARY==1 ||P[ip].AM_I_BOUNDARY== 2 )//bottom walls { P[ip].m = 0; //don't care the mass P[ip].T = 20; //can be change as wish } } cout<<"Random configuration created: SUCCESS"<<endl<<endl; }
StaticMeshInstance::StaticMeshInstance(const AssetPtr<StaticMesh>& mesh, const AssetPtr<Material>& material) : _mesh(mesh), _material(material) { set_radius(_mesh->radius()); }
Sphere::Sphere(const Aabb& aabb) { set_position((aabb.min_vtx()+aabb.max_vtx())*0.5f); float length = (aabb.max_vtx()-aabb.min_vtx()).Length(); set_radius(length*0.5f); }