inline TYPE VECTOR_CMOV( TYPE a, TYPE b, TYPE c, TYPE d){
    TYPE z = VECTOR_EQUAL  ( a, b );
//    return _mm_blendv_epi8( d, c, z );
    TYPE g = VECTOR_AND   ( c, z );
    TYPE h = VECTOR_ANDNOT( z, d );
    return VECTOR_OR         ( g, h );
}
Esempio n. 2
0
/**
 * Returns the intersections of two vectors of circles.
 * @ret: the number of intersection [0,1,2]
 */
static inline VECTOR
__attribute__((__always_inline__,__gnu_inline__,__nonnull__,__artificial__))
circle_get_intersection_ps(const VECTOR p1x, const VECTOR p1y, const VECTOR p2x,
			   const VECTOR p2y, const VECTOR r1, const VECTOR r2,
			   VECTOR *restrict retx, VECTOR *restrict rety)
{
    VECTOR d = distance(p1x, p1y, p2x, p2y);

    // no solutions, the circles are separate || the circles are coincident || no solutions because one circle is contained within the other
    // => infinite number of solutions possible
    VECTOR one_sol = VECTOR_GE(r1 + r2, d);
    one_sol = VECTOR_AND(one_sol, VECTOR_LE(VECTOR_ABS(r1 - r2), d));
    one_sol = VECTOR_AND(one_sol, VECTOR_NE(VECTOR_ZERO(), d));

    VECTOR a = (r1*r1 - r2*r2 + d*d) / (d + d);
    VECTOR v = r1*r1 - a*a;
    VECTOR h = VECTOR_SQRT(v);

    VECTOR dx = (p2x - p1x) / d;
    VECTOR dy = (p2y - p1y) / d;
    VECTOR p3x = p1x + a * dx;
    VECTOR p3y = p1y + a * dy;

    dx *= h;
    dy *= h;
    VECTOR p4x = p3x + dy;
    VECTOR p4y = p3y - dx;
inline TYPE VECTOR_GET_SIGN_BIT(TYPE a, TYPE m){
    TYPE b = VECTOR_AND(a, m);
    return b;
}
//
// ON INVERSE LE SIGNE DE LA DONNEE EN FONCTION DU SIGNE
//
inline TYPE VECTOR_invSIGN2( TYPE a, TYPE z){
    TYPE g = VECTOR_AND   ( a,             z );
    TYPE h = VECTOR_ANDNOT( VECTOR_NEG(a), z );
    return VECTOR_OR      ( g, h );
}