예제 #1
0
inline sphere<T,N> shiftCtrlP(const sphere<T,N>& a,
                              const vec<T,N>& mpos,
                              const vec<T,N>& mshift,
                              const vec<T,N>& mindim,
                              const uint8_t * mask)
{
    if (mask) {
        if (pnw::get_bit(*mask, 0)) { a.c() += mshift; }
        if (pnw::get_bit(*mask, 1)) { a.r() -= dot(normalize(a.c() - mpos), mshift); }
    }
    return a;
}
예제 #2
0
/*! Inverse Operation of \c sphere<T,N>_getSub_box2f(). */
inline void
sphere<T,N>_getRel_box2f(const box2f& a,
                         const sphere<T,N>& b,
                         sphere<T,N>& ba)
{
    vec2f ad; box2f_rdDim(a, &ad);
    vec3f_set(&ba.c(),
              (b.c()(0) - a.l(0)) / ad(0),
              (b.c()(1) - a.l(1)) / ad(1),
              b.c()(2));		/* z is ignored */
    ba.r() = b.r() / mean(ad(0), ad(1));
    if (ad(0) != ad(1)) {
        PTODO("ad's components not all equal => may result in an ellipse\n");
    }
}
예제 #3
0
/*! Sub-Sphere when \p ba is viewed relative to \p a and put
 * result in \p b.
 * The inverse operation of \c sphere<T,N>_getRel().
 */
inline void
sphere<T,N>_getSub(const box<T,N>& a,
                   const sphere<T,N>& ba,
                   sphere<T,N>& b)
{
    vec3f ad; box3f_rdDim(a, &ad);
    vec3f_set(&b.c(),
              a.l(0) + ad(0) * ba.c()(0),
              a.l(1) + ad(1) * ba.c()(1),
              a.l(2) + ad(2) * ba.c()(2));
    b.r() = ba.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");
    }
}
예제 #4
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;
}
예제 #5
0
 /*! Centered Scale Radius of \p a the factor \p f. */
 friend pure sphere scale(const sphere& a, T f) { return sphere(a.c(), f * a.r()); }