Example #1
0
 /**
  * Return true iff the projection of loop onto line (v0, v1) is completely
  * between v0 and v1.
  */
 bool loop_is_valid(const MatrixFr& loop,
         const VectorF& v0, const VectorF& v1) {
     VectorF dir = v1 - v0;
     Float dir_sq_len = dir.squaredNorm();
     if (dir_sq_len == 0.0) {
         throw RuntimeError("Zero edge encountered.");
     }
     VectorF proj = (loop.rowwise() - v0.transpose()) * dir / dir_sq_len;
     return ((proj.array() > 0.0).all() && (proj.array() < 1.0).all());
 }
Example #2
0
MatrixF IsotropicTransforms::fit(
        const VectorF& from_dir, const VectorF& to_dir) const {
    const Float tol = 1e-12;

    for (const auto& rot1 : m_rotations) {
        for (const auto& ref : m_reflections) {
            for (const auto& rot2 : m_rotations) {
                VectorF dir = rot1 * ref * rot2 * from_dir;
                Float dist = (dir - to_dir).squaredNorm();
                if (dist < tol) {
                    return rot1 * ref * rot2;
                }
            }
        }
    }
    std::stringstream err_msg;
    err_msg << "Cannot find isotropic transformation that maps <"
        << from_dir.transpose() << "> to <"
        << to_dir.transpose() << ">" << std::endl;
    throw RuntimeError(err_msg.str());
}
Example #3
0
    std::list<std::function<MatrixFr(const MatrixFr&)> > get_tiling_operators(
            const VectorF& ref_pt,
            const VectorF& cell_size,
            const std::vector<VectorI>& indices) {

        std::list<std::function<MatrixFr(const MatrixFr&)> > operators;
        for (auto index : indices) {
            VectorF cur_pt = cell_size.cwiseProduct(index.cast<Float>());
            VectorF offset = cur_pt - ref_pt;
            operators.push_back(
                    [=] (const MatrixFr& vertices) {
                        MatrixFr result(vertices);
                        result.rowwise() += offset.transpose();
                        return result;
                    });
        }
        return operators;
    }