Пример #1
0
inline pure sqr<T,N> box2f_rdISqr_sqr2f(const box<T,N>& a, T f)
{
    sqr<T,N> b;
    b.c() = a.cen();
    auto dim = a.dim()
        b.r = f*std::min(dim(0), dim(1))/2;
    return b;
}
Пример #2
0
/*! Sub-Sphere-Shell when \p ba is viewed relative to \p a.
 * The inverse operation of \c getRel().
 */
template<class T, std::size_t N> inline pure cring<T> getSub(const cring<T>& ba,
                                                             const box<T,N>& a) {
    auto ad = a.dim();
    if (ad(0) != ad(1)) { PTODO("ad(0) != ad(1) => may result in an ellipse\n"); } // TODO: ad(0) != ad(1) => may result in an ellipse
    const T m = mean(ad(0), ad(1));
    return cring<T>(a(1) + ad * ba.c(),
                    ba.ri() * m,
                    ba.ro() * m);
}
Пример #3
0
/*! Fit Square \p sqr precisely Inside (Bounding) Box extents \p ext.
 * \return 1 if extents were changed, -1 if type not supported, 0 otherwise.
 */
inline int fit_in(sqr<T,N>& sqr,
                  const box<T,N> ext)
{
    int ret = 1;
    auto cen = ext.cen();
    auto dim = ext.dim();
    set(sqr, cen(0), cen(1),
        std::min(dim(0), dim(1))/2); /* use inner square */
    return ret;
}
Пример #4
0
/*! The inverse operation of \c getSub(). */
template<class T, std::size_t N> inline pure cring<T> getRel(const box<T,N>& a,
                                                             const cring<T>& b) {
    auto ad = a.dim();
    if (ad(0) != ad(1)) { PTODO("ad(0) != ad(1) => may result in an ellipse\n"); }
    const T m = mean(ad(0), ad(1));
    return cring<T>((b.c()(0) - a.l(0)) / ad(0),
                    (b.c()(1) - a.l(1)) / ad(1),
                    b.ri() / m,
                    b.ro() / m);
}
Пример #5
0
/*! Inverse Operation of \c sphere<T,N>_getSub(). */
inline sphere<T,N> getRel(const box<T,N>& a,
                          const sphere<T,N>& b)
{
    auto ad = a.dim();
    sphere<T,N> ba((b.c() - a.l()) / ad,
                   b.r() / pnw::mean(ad(0), ad(1), ad(2)));
    if (ad(0) != ad(1) or
        ad(1) != ad(2) or
        ad(2) != ad(0)) {
        PTODO("ad's components not all equal => may result in an ellipse\n");
    }
    return ba;
}
Пример #6
0
/*! Outer Sphere of \p a scaled the factor \p f. */
template<class T, std::size_t N> inline pure sphere<T,N> outer_sphere(const box<T,N>& a, T f = 1) { return sphere<T,N>(a.cen(), f * norm(a.dim()) / 2); }