Exemplo n.º 1
0
Sphere3D get_enclosing_sphere(const Vector3Ds &vs) {
  Sphere3Ds ss(vs.size());
  for (unsigned int i = 0; i < vs.size(); ++i) {
    ss[i] = Sphere3D(vs[i], 0);
  }
  return get_enclosing_sphere(ss);
}
Exemplo n.º 2
0
void test_uniform(std::string name, unsigned int n, double eps) {
  set_log_level(SILENT);
  set_check_level(NONE);
  BoundingBox3D bb(Vector3D(0, 0, 0), Vector3D(10, 10, 10));
  Vector3Ds pts;
  for (unsigned int i = 0; i < n; ++i) {
    pts.push_back(get_random_vector_in(bb));
  }
  KNN knn(pts.begin(), pts.end());
  test(name + " uniform", pts, knn, eps);
}
Exemplo n.º 3
0
Arquivo: io.cpp Projeto: drussel/imp
IMPALGEBRA_BEGIN_NAMESPACE

void write_pts(const Vector3Ds &vs, base::TextOutput out) {
  for (unsigned int i=0; i< vs.size(); ++i) {
    out.get_stream() << spaces_io(vs[i]) << "\n";
  }
}
Exemplo n.º 4
0
Arquivo: io.cpp Projeto: drussel/imp
Vector3Ds read_pts(base::TextInput oin) {
  std::istream &in= oin;
  Vector3Ds ret;
  while (true) {
    char buf[2000];
    in.getline(buf, 2000);
    if (!in) break;;
    if (buf[0]=='#') continue;
    std::istringstream iss(buf);
    IMP::Float x,y,z;
    iss >> x >> y >> z;
    if (!iss) {
      throw IMP::base::ValueException((std::string("Unable to parse line ")
                                 + buf).c_str());
    }
    Vector3D v(x,y,z);
    ret.push_back(v);
  }
  return ret;
}
Exemplo n.º 5
0
Triangle3D get_largest_triangle(const Vector3Ds &points) {
   double max_dist = 0;
   Vector3Ds triple(3);
   for (unsigned int i = 0 ; i < points.size() ; i++) {
     for (unsigned int j = 0 ; j < points.size() ;j++) {
       double dist = algebra::get_squared_distance(points[i],points[j]);
       if (dist > max_dist) {
         max_dist = dist;
         triple[0] = points[i];
         triple[1] = points[j];
       }
     }
   }
    algebra::Segment3D seg(triple[0],triple[1]);
    max_dist=0;
    for (unsigned int i = 0 ; i < points.size();i++) {
      double dist = algebra::get_distance(seg,points[i]);
      if (dist > max_dist) {
        max_dist = dist;
        triple[2] =points[i];
      }
    }
    return Triangle3D(triple[0],triple[1],triple[2]);
}