Пример #1
0
///////////////////////////////////////////////////////////////////////////////
// Linear function
//
///////////////////////////////////////////////////////////////////////////////
GEM_EXTERN void linearFunc(float x, float *ret, int numDimen, int npnts, float *pnts)
{
    int nspans = npnts - 1;
    if (nspans < 1)          // illegal
        return;

    x = FLOAT_CLAMP(x) * nspans;
    int span = static_cast<int>(x);

    // find the correct 2-point span of the linear list
    if (span >= nspans)
            span = nspans;
    x -= span;
    pnts += (span * numDimen);
    for (int i = 0; i < numDimen; i++)
    {
        ret[i] = pnts[0 * numDimen] * (1.f - x) + pnts[1 * numDimen] * x;
        pnts++;     // advance to the next dimension
    }
}
Пример #2
0
GEM_EXTERN void splineFunc(double x, double *ret, int numDimen, int nknots, double *knot)
{
    int nspans = nknots - 4;
    if (nspans < 0)         // illegal case
        return;

    // find the correct 4-point span of the spline
    x = FLOAT_CLAMP(x) * nspans;
    int span = static_cast<int>(x);
    x -= span;              // get decimal part of span
    knot += (span * numDimen);

    // Evalute the span cubic at x using Horner's rule
    double c0, c1, c2, c3;
    for (int i = 0; i < numDimen; i++)
    {
        c3 = CR00*knot[0 * numDimen]
           + CR01*knot[1 * numDimen]
           + CR02*knot[2 * numDimen]
           + CR03*knot[3 * numDimen];

        c2 = CR10*knot[0 * numDimen]
           + CR11*knot[1 * numDimen]
           + CR12*knot[2 * numDimen]
           + CR13*knot[3 * numDimen];

        c1 = CR20*knot[0 * numDimen]
           + CR21*knot[1 * numDimen]
           + CR22*knot[2 * numDimen]
           + CR23*knot[3 * numDimen];

        c0 = CR30*knot[0 * numDimen]
           + CR31*knot[1 * numDimen]
           + CR32*knot[2 * numDimen]
           + CR33*knot[3 * numDimen];

        ret[i] = ((c3*x + c2)*x + c1)*x + c0;
        knot++;     // advance to the next dimension
    }
}
Пример #3
0
void pix_hit :: min_distanceCallback(void *data, t_floatarg val)
{
  GetMyClass(data)->set_min_distance(FLOAT_CLAMP(val));
}
Пример #4
0
void pix_hit :: minimumCallback(void *data, t_floatarg val)
{
  int n = static_cast<int>(FLOAT_CLAMP(val));
  GetMyClass(data)->minimum(n);
}
Пример #5
0
void pix_hit :: thresholdCallback(void *data, t_floatarg val)
{
  GetMyClass(data)->threshold(FLOAT_CLAMP(val));
}
Пример #6
0
void clamp<quint16>(float* r, float* g, float* b)
{
    FLOAT_CLAMP(r);
    FLOAT_CLAMP(g);
    FLOAT_CLAMP(b);
}
Пример #7
0
static void hsv2rgb_float(t_hsv2rgb *x, t_floatarg h, t_floatarg s, t_floatarg v)
{
  t_atom argv[3];
  float r=0, g=0, b=0;

  h = FLOAT_CLAMP(h);
  s = FLOAT_CLAMP(s);
  v = FLOAT_CLAMP(v);

  // convert hue to degrees
  h *= 360.f;
	
  if (s == 0.0)		// black and white
    {
      r = g = b = v;
    }
  else
    {
      if (h == 360.0)			// 360 == 0 degrees
        h = 0.0f;
      h /= 60.0f;				// hue is now [0, 6]
      {
        int i = (int)floor(h);
        float f = h - i;		// f is the fractional part of h
        float p = v * (1 - s);
        float q = v * (1 - s * f);
        float t = v * (1 - s * (1 - f));
        
        switch (i)
          {
          case 0:
            r = v;
            g = t;
            b = p;
            break;
          case 1:
            r = q;
            g = v;
            b = p;
            break;
          case 2:
            r = p;
            g = v;
            b = t;
            break;
          case 3:
            r = p;
            g = q;
          b = v;
          break;
          case 4:
            r = t;
            g = p;
            b = v;
            break;
          case 5:
            r = v;
            g = p;
            b = q;
            break;
          }
      }
    }
  SETFLOAT(&argv[0], r);
  SETFLOAT(&argv[1], g);
  SETFLOAT(&argv[2], b);
  outlet_list(x->t_out1, &s_list, 3, argv);
}
Пример #8
0
void pix_data :: yPos(t_float f)
{
  m_position[1]=FLOAT_CLAMP(f);
}