int main() { const int N=10000; CGAL::Random rnd = CGAL::get_default_random(); std::cout << "seed: " << rnd.get_seed() << std::endl; // generator for random data points in the square ( (-1,-1), (1,1) ) Random_points_iterator rpit(1.0, rnd); // construct list containing N random points std::list<Point> all_points(N_Random_points_iterator(rpit,0), N_Random_points_iterator(N)); // add some interesting points all_points.push_back(Point(0., 0.)); all_points.push_back(Point(-CGAL_PI/10.+0.1, -CGAL_PI/10.+0.1)); all_points.push_back(Point(1., 1.)); all_points.push_back(Point(0., 1.)); all_points.push_back(Point(0.3, 0.4)); all_points.push_back(Point(0.2, 0.3)); all_points.push_back(Point(0., 0.1)); run<Traits>(all_points, rnd); run<Traits_with_info>(all_points, rnd); return 0; }
void view::points_changed() { points_ = all_points(); speed_.clear(); for (size_t i = 0; i < points_.size(); ++i) { size_t anchor =get_anchor(i); if (anchor_points()[anchor].speed > 0) speed_.push_back(anchor_points()[anchor].speed); else speed_.push_back(settings_.speed); } if(speed_.size()>1) speed_.back() = 0; length_ = 0; dist_.resize(points_.size()); if(points_.size()>0) { dist_[0] = 0; FIXME(Не нуачо классный код (unsigned)) for (size_t i = 0; i < points_.size() - 1; ++i) { double dst = cg::distance2d(points_[i], points_[i+1]); length_ += dst; dist_[i + 1] = length_; } }
void ctrl::reset_points() { std::vector<ani::point_pos> points = std::move(all_points()); //polyline_chart_t::set_points(to_chart_points(points)); //for (size_t i = 0; i < points.size(); ++i) // if (!is_anchor(i)) // polyline_chart_t::set_point_image(i, ":/images/track-point.bmp"); }
Real MultiAppNearestNodeTransfer::bboxMinDistance(Point p, MeshTools::BoundingBox bbox) { std::vector<Point> source_points = {bbox.first, bbox.second}; std::vector<Point> all_points(8); for (unsigned int x = 0; x < 2; x++) for (unsigned int y = 0; y < 2; y++) for (unsigned int z = 0; z < 2; z++) all_points[x + 2*y + 4*z] = Point(source_points[x](0), source_points[y](1), source_points[z](2)); Real min_distance = 0.; for (unsigned int i = 0; i < 8; i++) { Real distance = (p - all_points[i]).norm(); if (distance < min_distance) min_distance = distance; } return min_distance; }
void compute_projections(const Particles& all_particles, const Particles& lig_particles, unsigned int projection_number, double pixel_size, double resolution, boost::ptr_vector<Projection>& projections, int image_size) { // get coordinates, radius and mass IMP::algebra::Vector3Ds all_points(all_particles.size()); std::vector<double> all_radii(all_particles.size()); for (unsigned int i = 0; i < all_particles.size(); i++) { all_points[i] = core::XYZ(all_particles[i]).get_coordinates(); all_radii[i] = core::XYZR(all_particles[i]).get_radius(); } IMP::algebra::Vector3Ds lig_points(lig_particles.size()); std::vector<double> lig_radii(lig_particles.size()); std::vector<double> lig_mass(lig_particles.size()); for (unsigned int i = 0; i < lig_particles.size(); i++) { lig_points[i] = core::XYZ(lig_particles[i]).get_coordinates(); lig_radii[i] = core::XYZR(lig_particles[i]).get_radius(); lig_mass[i] = atom::Mass(lig_particles[i]).get_mass(); } int axis_size = image_size; // use image_size if given if (!(image_size > 0)) { double max_dist = compute_max_distance(all_points); static IMP::em::KernelParameters kp(resolution); double radius = 3.0; const IMP::em::RadiusDependentKernelParameters& params = kp.get_params(radius); double wrap_length = 2 * params.get_kdist() + 1.0; axis_size = (int)((max_dist + 2 * wrap_length + 2 * pixel_size) / pixel_size + 2); if (axis_size <= image_size) axis_size = image_size; } // storage for rotated points IMP::algebra::Vector3Ds rotated_points(all_points.size()); IMP::algebra::Vector3Ds rotated_ligand_points(lig_points.size()); // points on a sphere IMP::algebra::SphericalVector3Ds spherical_coords; quasi_evenly_spherical_distribution(projection_number, spherical_coords, 1.0); for (unsigned int i = 0; i < spherical_coords.size(); i++) { // convert sphere coordinate to rotation IMP::algebra::SphericalVector3D v = spherical_coords[i]; double cy = cos(v[1] / 2.0); double cz = cos(v[2] / 2.0); double sy = sin(v[1] / 2.0); double sz = sin(v[2] / 2.0); // this is a rotation about z axis by an angle v[2] // followed by rotation about y axis by an angle v[1] IMP::algebra::Rotation3D r(cy * cz, sy * sz, sy * cz, cy * sz); // rotate points for (unsigned int p_index = 0; p_index < all_points.size(); p_index++) rotated_points[p_index] = r * all_points[p_index]; for (unsigned int p_index = 0; p_index < lig_points.size(); p_index++) rotated_ligand_points[p_index] = r * lig_points[p_index]; // project std::auto_ptr<Projection> p( new Projection(rotated_points, rotated_ligand_points, lig_radii, lig_mass, pixel_size, resolution, axis_size)); p->set_rotation(r); p->set_axis(IMP::algebra::Vector3D(v.get_cartesian_coordinates())); p->set_id(i); // rasmol // std::cout << "#projection " << i+1 <<"\nreset\nrotate Z " //<< IMP_RAD_2_DEG(v[2]); // std::cout << "\nrotate Y -" << IMP_RAD_2_DEG(v[1]) << std::endl; // chimera // std::cout << "#projection " << i+1 //<<"\nreset;turn x 180; turn z -" << IMP_RAD_2_DEG(v[2]); // std::cout << ";turn y -" << IMP_RAD_2_DEG(v[1]) //<< ";wait;sleep 3;"<< std::endl; // string file_name = "projection_" + // string(boost::lexical_cast<string>(i+1)) + ".pgm"; // p.write_PGM(file_name); projections.push_back(p.release()); } }