コード例 #1
0
ファイル: ProjectionSphere.cpp プロジェクト: salilab/imp
void ProjectionSphere::get_adjacent_rotations_and_axes(const IMP::algebra::Vector3Ds& curr_axes,
                                                       double angle_thr,
                                                       IMP::algebra::Rotation3Ds& rotations,
                                                       IMP::algebra::Vector3Ds& axes) const {

  // convert angle threshold into euclidean distance
  double radius = 2*sin(angle_thr/2);
  double radius2 = radius*radius;

  for (unsigned int i = 0; i < curr_axes.size(); i++) {
    IMP::algebra::BoundingBox3D bb(curr_axes[i]);
    bb += radius;
    Grid::ExtendedIndex lb = grid_.get_extended_index(bb.get_corner(0)),
                        ub = grid_.get_extended_index(bb.get_corner(1));

    for (Grid::IndexIterator it = grid_.indexes_begin(lb, ub);
       it != grid_.indexes_end(lb, ub); ++it) {
      for (unsigned int vIndex = 0; vIndex < grid_[*it].size(); vIndex++) {
        int direction_index = grid_[*it][vIndex];
        double dist2 = algebra::get_squared_distance(curr_axes[i],
                                                     axes_[direction_index]);
        if (dist2 <= radius2) {
          rotations.push_back(rotations_[direction_index]);
          axes.push_back(axes_[direction_index]);
        }
      }
    }
  }
}
コード例 #2
0
ファイル: Projection.cpp プロジェクト: AljGaber/imp
double compute_max_distance(const IMP::algebra::Vector3Ds& coordinates) {
  double max_dist2 = 0;
  for (unsigned int i = 0; i < coordinates.size(); i++) {
    for (unsigned int j = i + 1; j < coordinates.size(); j++) {
      double dist2 =
          IMP::algebra::get_squared_distance(coordinates[i], coordinates[j]);
      if (dist2 > max_dist2) max_dist2 = dist2;
    }
  }
  return sqrt(max_dist2);
}
コード例 #3
0
ファイル: Projection.cpp プロジェクト: AljGaber/imp
void Projection::init(const IMP::algebra::Vector3Ds& points,
                      double max_radius, int axis_size) {
  // determine the image size needed to store the projection
  x_min_ = y_min_ = std::numeric_limits<float>::max();
  x_max_ = y_max_ = std::numeric_limits<float>::min();

  // determine translation to center
  algebra::Vector3D center(0.0, 0.0, 0.0);
  for (unsigned int i = 0; i < points.size(); i++) {
    x_min_ = std::min(x_min_, points[i][0]);
    y_min_ = std::min(y_min_, points[i][1]);
    x_max_ = std::max(x_max_, points[i][0]);
    y_max_ = std::max(y_max_, points[i][1]);
    center += points[i];
  }
  center /= points.size();

  static IMP::em::KernelParameters kp(resolution_);
  const IMP::em::RadiusDependentKernelParameters& params =
      kp.get_params(max_radius);

  double wrap_length = 2 * params.get_kdist() + 1.0;
  x_min_ = x_min_ - wrap_length - scale_;
  y_min_ = y_min_ - wrap_length - scale_;
  x_max_ = x_max_ + wrap_length + scale_;
  y_max_ = y_max_ + wrap_length + scale_;

  int width = (int)((x_max_ - x_min_) / scale_ + 2);
  int height = (int)((y_max_ - y_min_) / scale_ + 2);
  int size = std::max(width, height);

  // the determined size should be below axis size if specified
  if (axis_size > 0 && size <= axis_size)
    size = axis_size;
  else {
    IMP_WARN("wrong size estimate " << size << " vs. estimate " << axis_size
              << std::endl);
  }
  this->resize(boost::extents[size][size]);

  int i = 0, j = 0;
  get_index_for_point(center, i, j);
  t_i_ = size / 2 - i;
  t_j_ = size / 2 - j;
}
コード例 #4
0
ファイル: Projector.cpp プロジェクト: salilab/imp
int Projector::estimate_image_size(const IMP::algebra::Vector3Ds& points) const {
  // estimate max image size
  IMP::algebra::Vector3D centroid = IMP::algebra::get_centroid(points);
  double max_rad2 = 0;
  for (unsigned int i = 0; i < points.size(); i++) {
    double dist2 = IMP::algebra::get_squared_distance(points[i], centroid);
    if (dist2 > max_rad2) max_rad2 = dist2;
  }

  // estimate max image size
  double max_dist =  2*sqrt(max_rad2); //compute_max_distance(points);
  static IMP::em::KernelParameters kp(resolution_);
  double wrap_length = 2 * kp.get_rkdist() + 1.0;
  int axis_size =
      (int)((max_dist + 2 * wrap_length + 2 * pixel_size_) / pixel_size_ + 2);
  return axis_size;
}
コード例 #5
0
ファイル: Projection.cpp プロジェクト: j-ma-bu-l-l-ock/imp
void Projection::project(const IMP::algebra::Vector3Ds& points,
                         const std::vector<double>& mass) {
  // get mask
  const std::vector<MaskCell>& mask = get_sphere_mask();
  int i, j;
  for (unsigned int p_index = 0; p_index < points.size(); p_index++) {
    // project
    if (get_index_for_point(points[p_index], i, j)) {
      for (unsigned int mask_index = 0; mask_index < mask.size();
           mask_index++) {
        int i_shift = mask[mask_index].i;
        int j_shift = mask[mask_index].j;
        double density = mask[mask_index].d;
        (*this)[i + i_shift][j + j_shift] += mass[i] * density;
      }
    }
  }
}