Ejemplo n.º 1
0
inline std::pair<typename Cylinder<T_>::position_type,
                 typename Cylinder<T_>::length_type>
projected_point(Cylinder<T_> const& obj,
                typename Cylinder<T_>::position_type const& pos)
{
    typedef typename Cylinder<T_>::length_type length_type;

    // The projection lies on the z-axis.
    std::pair<length_type, length_type> r_z(to_internal(obj, pos));
    return std::make_pair(
        add(obj.position(), multiply(obj.unit_z(), r_z.second)),
        r_z.first);
}
Ejemplo n.º 2
0
// Given two matches, match_xy and match_xz infer the 
// match between yz. This requies coord[0] of the input 
// matches to be referring to the same sequence
// This returns the minimal matching region, it could possibly be extended
Match Match::infer(const Match& match_xy, const Match& match_xz)
{
    assert(match_xy.coord[0].seqlen == match_xz.coord[0].seqlen);

    // Calculate the max/min start/end coordinates of coord[0]
    int s = std::max(match_xy.coord[0].interval.start, match_xz.coord[0].interval.start);
    int e = std::min(match_xy.coord[0].interval.end, match_xz.coord[0].interval.end);

    // These are the coordinates in frame X
    SeqCoord r_y(s, e, match_xy.coord[0].seqlen);
    SeqCoord r_z(s, e, match_xz.coord[0].seqlen);

    // Translate into the desired frame
    SeqCoord t_y = match_xy.translate(r_y);
    SeqCoord t_z = match_xz.translate(r_z);

    // Set the new lengths of the seqcoords
    t_y.seqlen = match_xy.coord[1].seqlen;
    t_z.seqlen = match_xz.coord[1].seqlen;

    return Match(t_y, t_z, match_xy.isRC() != match_xz.isRC(), -1);
}