• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ MIN3函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中MIN3函数的典型用法代码示例。如果您正苦于以下问题:C++ MIN3函数的具体用法?C++ MIN3怎么用?C++ MIN3使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MIN3函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: LAPACKE_cgb_trans

void LAPACKE_cgb_trans( int matrix_order, lapack_int m, lapack_int n,
                        lapack_int kl, lapack_int ku,
                        const lapack_complex_float *in, lapack_int ldin,
                        lapack_complex_float *out, lapack_int ldout )
{
    lapack_int i, j;

    if( in == NULL || out == NULL ) return;

    if( matrix_order == LAPACK_COL_MAJOR ) {
        for( j = 0; j < MIN( ldout, n ); j++ ) {
            for( i = MAX( ku-j, 0 ); i < MIN3( ldin, m+ku-j, kl+ku+1 );
                 i++ ) {
                out[(size_t)i*ldout+j] = in[i+(size_t)j*ldin];
            }
        }
    } else if ( matrix_order == LAPACK_ROW_MAJOR ) {
        /* TODO: interchange loops for performance.
         * This is just reference impemeltation.
         */
        for( j = 0; j < MIN( n, ldin ); j++ ) {
            for( i = MAX( ku-j, 0 ); i < MIN3( ldout, m+ku-j, kl+ku+1 );
                 i++ ) {
                out[i+(size_t)j*ldout] = in[(size_t)i*ldin+j];
            }
        }
    }
}
开发者ID:BOHICAMAN,项目名称:OpenBLAS,代码行数:28,代码来源:lapacke_cgb_trans.c


示例2: ed

int  ed(WorkPtr work, int s1, int s2, int rcflag) {
  // if rcflag==1 then we study the rc(s2) rather than s2
  int row, col, l1, l2, r1, r2, curr,prev;

  int num_words_1, num_words_2;
  int score=0;
  void *x, *y;
  dmat1Arr dmat[2];
  int the_min,min_min=0;


  dmat[0] = work->fn_data;
  dmat[1] = work->fn_data+MAX_SEQ_LEN;

  //memset(dmat[0],0,2*sizeof(dmatEntry)*MAX_SEQ_LEN);

  // rather than comparing the entire ESTs, we narrow down
  // the regions on the ESTs where the match could be
  get_bounds(work,s1, s2, &l1, &r1);  // bounds for s1
  get_bounds(work,s2, s1, &l2, &r2);  // bounds for s2
  if (r1-l1< 4)return (10*window_len);// don't bother if not there
  l1 = MAX(0,l1-window_len);     // region could star 
  l2 = MAX(0,l2-window_len);
  r1 = MIN(r1+window_len,seqInfo[s1].len);
  r2 = MIN(r2+window_len,seqInfo[s2].len);
  NUM_dfn++;
  num_words_1 = r1-word_len+1;
  num_words_2 = r2-word_len+1;

  create_word_lists(work,s1, s2, rcflag);
  prev=0;
  curr=1;
  for(row=0; row<=r1; row++) dmat[0][row].f = OPEN;
  for(col=l2; col<r2 && min_min  > theta ; col++) {
    dmat[curr][l1].f=dmat[curr][l1].m=0;
    dmat[curr][l1].e=OPEN;
    for (row=l1+1; row<=r1 && min_min > theta; row++) {
       the_min=0;
       dmat[curr][row].f = 
          MIN3(dmat[prev][row].e+EXTEND+OPEN,
               dmat[prev][row].f+EXTEND,
               dmat[prev][row].g+OPEN+EXTEND);
       if (dmat[curr][row].f < the_min) the_min = dmat[curr][row].f;
       dmat[curr][row].g = dmat[prev][row-1].m+
	 cost[work->word1[row-1]][work->word2[col]];
       if (dmat[curr][row].g < the_min) the_min = dmat[curr][row].g;
       dmat[curr][row].e = 
          MIN3(dmat[curr][row-1].e+EXTEND,
               dmat[curr][row-1].f+EXTEND+OPEN,
               dmat[curr][row-1].g+OPEN+EXTEND);
       if (dmat[curr][row].e < the_min) the_min = dmat[curr][row].e;
       dmat[curr][row].m=the_min;
       if (the_min<min_min) min_min=the_min;
    }
    prev = curr;
    curr = 1-curr;
  }

  return min_min;
}
开发者ID:shaze,项目名称:wcdest,代码行数:60,代码来源:ed.c


示例3: edpair

int  edpair(WorkPtr work, int s1, int s2, int rcflag) {
  // if rcflag==1 then we study the rc(s2) rather than s2
  int row, col, l1, l2, r1, r2, curr,prev;

  int num_words_1, num_words_2;
  int score=0;
  void *x, *y;
  dmat1Arr dmat[2];
  int the_min,min_min=0;


  dmat[0] = work->fn_data;
  dmat[1] = work->fn_data+MAX_SEQ_LEN;

  //memset(dmat[0],0,2*sizeof(dmatEntry)*MAX_SEQ_LEN);

  l1 = 0;     // region could star 
  l2 = 0;
  r1 = seqInfo[s1].len;
  r2 = seqInfo[s2].len;
  NUM_dfn++;
  num_words_1 = r1-word_len+1;
  num_words_2 = r2-word_len+1;

  create_word_lists(work,s1, s2, rcflag);
  prev=0;
  curr=1;
  for(row=0; row<=r1; row++) dmat[0][row].f = OPEN;
  for(col=l2; col<r2 && min_min  > theta ; col++) {
    dmat[curr][l1].f=dmat[curr][l1].m=0;
    dmat[curr][l1].e=OPEN;
    for (row=l1+1; row<=r1 && min_min > theta; row++) {
       the_min=0;
       dmat[curr][row].f = 
          MIN3(dmat[prev][row].e+EXTEND+OPEN,
               dmat[prev][row].f+EXTEND,
               dmat[prev][row].g+OPEN+EXTEND);
       if (dmat[curr][row].f < the_min) the_min = dmat[curr][row].f;
       dmat[curr][row].g = dmat[prev][row-1].m+
	 cost[work->word1[row-1]][work->word2[col]];
       if (dmat[curr][row].g < the_min) the_min = dmat[curr][row].g;
       dmat[curr][row].e = 
          MIN3(dmat[curr][row-1].e+EXTEND,
               dmat[curr][row-1].f+EXTEND+OPEN,
               dmat[curr][row-1].g+OPEN+EXTEND);
       if (dmat[curr][row].e < the_min) the_min = dmat[curr][row].e;
       dmat[curr][row].m=the_min;
       if (the_min<min_min) min_min=the_min;
    }
    prev = curr;
    curr = 1-curr;
  }

  return min_min;
}
开发者ID:shaze,项目名称:wcdest,代码行数:55,代码来源:ed.c


示例4: point_triangle_intersection

long point_triangle_intersection(Point3 p, Triangle3 t)
{
long sign12,sign23,sign31;
Point3 vect12,vect23,vect31,vect1h,vect2h,vect3h;
Point3 cross12_1p,cross23_2p,cross31_3p;

/* First, a quick bounding-box test:                               */
/* If P is outside triangle bbox, there cannot be an intersection. */

   if (p.x > MAX3(t.v1.x, t.v2.x, t.v3.x)) return(OUTSIDE);  
   if (p.y > MAX3(t.v1.y, t.v2.y, t.v3.y)) return(OUTSIDE);
   if (p.z > MAX3(t.v1.z, t.v2.z, t.v3.z)) return(OUTSIDE);
   if (p.x < MIN3(t.v1.x, t.v2.x, t.v3.x)) return(OUTSIDE);
   if (p.y < MIN3(t.v1.y, t.v2.y, t.v3.y)) return(OUTSIDE);
   if (p.z < MIN3(t.v1.z, t.v2.z, t.v3.z)) return(OUTSIDE);

/* For each triangle side, make a vector out of it by subtracting vertexes; */
/* make another vector from one vertex to point P.                          */
/* The crossproduct of these two vectors is orthogonal to both and the      */
/* signs of its X,Y,Z components indicate whether P was to the inside or    */
/* to the outside of this triangle side.                                    */

   SUB(t.v1, t.v2, vect12)
   SUB(t.v1,    p, vect1h);
   CROSS(vect12, vect1h, cross12_1p)
   sign12 = SIGN3(cross12_1p);      /* Extract X,Y,Z signs as 0..7 or 0...63 integer */

   SUB(t.v2, t.v3, vect23)
   SUB(t.v2,    p, vect2h);
   CROSS(vect23, vect2h, cross23_2p)
   sign23 = SIGN3(cross23_2p);

   SUB(t.v3, t.v1, vect31)
   SUB(t.v3,    p, vect3h);
   CROSS(vect31, vect3h, cross31_3p)
   sign31 = SIGN3(cross31_3p);

/* If all three crossproduct vectors agree in their component signs,  */
/* then the point must be inside all three.                           */
/* P cannot be OUTSIDE all three sides simultaneously.                */

   /* this is the old test; with the revised SIGN3() macro, the test
    * needs to be revised. */
#ifdef OLD_TEST
   if ((sign12 == sign23) && (sign23 == sign31))
      return(INSIDE);
   else
      return(OUTSIDE);
#else
   return ((sign12 & sign23 & sign31) == 0) ? OUTSIDE : INSIDE;
#endif
}
开发者ID:EduardMe,项目名称:GraphicsGems,代码行数:52,代码来源:triangleCube.c


示例5: color

/******************************************************************************
  FUNCTION: RGBtoHLS
  PURPOSE:     Convert from RGB to HLS
  IN: RGB color (0xBBGGRR)
  OUT: Hue, Saturation, Luminance from 0 to 1
  COPYRIGHT:1995-1997 Robert Mashlan
            Modified for LabWindows/CVI, 1999 Guillaume Dargaud
******************************************************************************/
void RGBtoHLS(const COLORREF rgb, double *H, double *L, double *S )
{
    double delta;
    double r = (double)((rgb    )&0xFF)/255;
    double g = (double)((rgb>> 8)&0xFF)/255;
    double b = (double)((rgb>>16)&0xFF)/255;
    double cmax = MAX3(r,g,b);
    double cmin = MIN3(r,g,b);
    *L=(cmax+cmin)/2.0;

    if(cmax == cmin)
    {
        *S = *H = 0; // it's really undefined
    }
    else
    {
        if(*L < 0.5)    *S = (cmax-cmin)/(cmax+cmin);
        else            *S = (cmax-cmin)/(2.0-cmax-cmin);

        delta = cmax - cmin;

        if(r == cmax)
        {
            *H = (g - b) / delta;
        }
        else
        {
            if(g == cmax) *H = 2.0 + (b-r) / delta;
            else          *H = 4.0 + (r-g) / delta;
        }
        *H /= 6.0;
        if (*H < 0.0) *H += 1;
    }
}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:42,代码来源:cardcolor.cpp


示例6: main

int main()
{
    int mult_2, mult_3, mult_5;
    int i, j, k, l;
    int prev_un;

#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif

    UN[0] = prev_un = 1;
    j = k = l = 0;

    for (i = 1; i < MAX_NUM; i++)
    {
        for (; (mult_2 = UN[j] * 2) <= prev_un; j++);
        for (; (mult_3 = UN[k] * 3) <= prev_un; k++);
        for (; (mult_5 = UN[l] * 5) <= prev_un; l++);
        UN[i] = prev_un = MIN3(mult_2, mult_3, mult_5);
        /*printf("%d, %d, %d, %d\n", mult_2, mult_3, mult_5, UN[i]);*/
    }
    printf("The 1500'th ugly number is %d.\n", UN[MAX_NUM-1]);

#ifndef ONLINE_JUDGE
    system("pause");
#endif
    return 0;
}
开发者ID:hasadent,项目名称:UVa-Online-Judge,代码行数:29,代码来源:136+-+Ugly+Numbers.c


示例7: main

int main(){
    scanf("%u",&t);
    t++;                                                // :D
    while(--t){
        scanf("%u %u",&n,&m);
        int32_t MAP[n][m],COSTS[n][m];
        for(int32_t i=0;i<n;++i){
            for (int32_t j=0;j<m;++j){
                scanf("%d",&MAP[i][j]);
                COSTS[i][j]=MAP[i][j];
            }
        }
        for (int32_t j=1;j<m;++j){
            for(int32_t i=0;i<n;++i){
                    if (i==0){
                        COSTS[i][j]+= MIN2(COSTS[i][j-1],COSTS[i+1][j-1]);
                    } else if (i==n-1){
                        COSTS[i][j]+= MIN2(COSTS[i][j-1],COSTS[i-1][j-1]);
                    } else  {
                        COSTS[i][j]+= MIN3(COSTS[i][j-1],COSTS[i+1][j-1],COSTS[i-1][j-1]);
                    }
            }
        }
        int32_t min=1<<30;
        for(int32_t i=0;i<n;++i){
            min=MIN2(min,COSTS[i][m-1]);
        }
        printf("%d\n",min);

    }
}
开发者ID:abkaluga,项目名称:themis,代码行数:31,代码来源:sto.cpp


示例8: _IsolateMinorE4

int  _IsolateMinorE4(graphP theGraph)
{
isolatorContextP IC = &theGraph->IC;

     if (IC->px != IC->x)
     {
         if (_MarkPathAlongBicompExtFace(theGraph, IC->r, IC->w) != OK ||
             _MarkPathAlongBicompExtFace(theGraph, IC->py, IC->r) != OK)
             return NOTOK;
     }
     else
     {
         if (_MarkPathAlongBicompExtFace(theGraph, IC->r, IC->px) != OK ||
             _MarkPathAlongBicompExtFace(theGraph, IC->w, IC->r) != OK)
             return NOTOK;
     }

     if (theGraph->functions.fpMarkDFSPath(theGraph, MIN3(IC->ux, IC->uy, IC->uz),
                                    MAX3(IC->ux, IC->uy, IC->uz)) != OK ||
         _MarkDFSPathsToDescendants(theGraph) != OK ||
         _JoinBicomps(theGraph) != OK ||
         _AddAndMarkUnembeddedEdges(theGraph) != OK)
         return NOTOK;

     theGraph->IC.minorType |= MINORTYPE_E4;
     return OK;
}
开发者ID:bgxcpku,项目名称:sagelib,代码行数:27,代码来源:graphIsolator.c


示例9: RGBtoHSV

static void
RGBtoHSV (double r, double g, double b, double *h, double *s, double *v)
{
  double min, max, delta;

  min = MIN3 (r, g, b );
  max = MAX3 (r, g, b );
  *v = max;				// v

  delta = max - min;

  if (max != 0) *s = delta / max;		// s
  else {
    *s = 0.0;
    *h = 0.0;
    return;
  }

  if (delta == 0.0)  *h = 0.0;			   // some shade of grey
  else if (r == max) *h = (g - b) / delta;	   // between yellow & magenta
  else if (g == max) *h = 2 + ( b - r ) / delta;   // between cyan & yellow
  else               *h = 4 + (r - g) / delta;	   // between magenta & cyan

#if 0
  if (isnan (*h)) {
    printf ("isnan %f %f %f %f %f %f\n", r, g, b, delta, max, min);
  }
#endif

  *h *= M_PI / 3.0;				// degrees
  if (*h < 0) *h += 2.0 * M_PI;

}
开发者ID:ChrisMoller,项目名称:gf3,代码行数:33,代码来源:buildcolourtable.c


示例10: rgbtohsv_int

struct hsv_color rgbtohsv_int(struct rgb_color rgb) {
    struct hsv_color hsv;
    uint8_T rgb_min, rgb_max;

    rgb_min = MIN3(rgb.r, rgb.g, rgb.b);
    rgb_max = MAX3(rgb.r, rgb.g, rgb.b);
    
    if((rgb_max-rgb_min)==0){
        return hsv;
    }else if(rgb_max==0){
        return hsv;
    }
    
    /* Compute hue */
    if (rgb_max == rgb.r) {
        hsv.hue = 0 + 43*(rgb.g - rgb.b)/(rgb_max - rgb_min);
    } else if (rgb_max == rgb.g) {
        hsv.hue = 85 + 43*(rgb.b - rgb.r)/(rgb_max - rgb_min);
    } else /* rgb_max == rgb.b */ {
        hsv.hue = 171 + 43*(rgb.r - rgb.g)/(rgb_max - rgb_min);
    }
    hsv.val = rgb_max;
    hsv.sat = 255*(long)(rgb_max - rgb_min)/rgb_max;
    return hsv;
}
开发者ID:Adeange1,项目名称:roboboat2015,代码行数:25,代码来源:rgbtohsv_int.c


示例11: MAX3

double OperaColors::RGB2HUE(double r, double g, double b) {
	double H;
	double m2 = MAX3(r, g, b);
	double m1 = CENTER(r, g, b);
	double m0 = MIN3(r, g, b);

	if (m2 == m1) {
		if (r == g) {
			H = 60;
			goto _RGB2HUE_END;
		}
		if (g == b) {
			H = 180;
			goto _RGB2HUE_END;
		}
		H = 60;
		goto _RGB2HUE_END;
	}
	double F = 60 * (m1 - m0) / (m2 - m0);
	if (r == m2) {
		H = 0 + F * (g - b);
		goto _RGB2HUE_END;
	}
	if (g == m2) {
		H = 120 + F * (b - r);
		goto _RGB2HUE_END;
	}
	H = 240 + F * (r - g);

_RGB2HUE_END:
	if (H < 0)
		H = H + 360;
	return H;
}
开发者ID:strogo,项目名称:StrongDC,代码行数:34,代码来源:BarShader.cpp


示例12: _IsolateMinorE4

int  _IsolateMinorE4(graphP theGraph)
{
    isolatorContextP IC = &theGraph->IC;

    if (IC->px != IC->x)
    {
        if (_MarkPathAlongBicompExtFace(theGraph, IC->r, IC->w) != OK ||
                _MarkPathAlongBicompExtFace(theGraph, IC->py, IC->r) != OK)
            return NOTOK;
    }
    else
    {
        if (_MarkPathAlongBicompExtFace(theGraph, IC->r, IC->px) != OK ||
                _MarkPathAlongBicompExtFace(theGraph, IC->w, IC->r) != OK)
            return NOTOK;
    }

    // Note: The x-y path is already marked, due to identifying E as the type of non-planarity minor
    if (theGraph->functions.fpMarkDFSPath(theGraph, MIN3(IC->ux, IC->uy, IC->uz),
                                          MAX3(IC->ux, IC->uy, IC->uz)) != OK ||
            _MarkDFSPathsToDescendants(theGraph) != OK ||
            _JoinBicomps(theGraph) != OK ||
            _AddAndMarkUnembeddedEdges(theGraph) != OK)
        return NOTOK;

    theGraph->IC.minorType |= MINORTYPE_E4;
    return OK;
}
开发者ID:nvcleemp,项目名称:planarity,代码行数:28,代码来源:graphIsolator.c


示例13: Rgb2Hsv

/**
 * @brief Convert an sRGB color to Hue-Saturation-Value (HSV)
 *
 * @param H, S, V pointers to hold the result
 * @param R, G, B the input sRGB values scaled in [0,1]
 *
 * This routine transforms from sRGB to the hexcone HSV color space.  The
 * sRGB values are assumed to be between 0 and 1.  The output values are
 *   H = hexagonal hue angle   (0 <= H < 360),
 *   S = C/V                   (0 <= S <= 1),
 *   V = max(R',G',B')         (0 <= V <= 1),
 * where C = max(R',G',B') - min(R',G',B').  The inverse color transformation
 * is given by Hsv2Rgb.
 *
 * Wikipedia: http://en.wikipedia.org/wiki/HSL_and_HSV
 */
void Rgb2Hsv(num *H, num *S, num *V, num R, num G, num B)
{
	num Max = MAX3(R, G, B);
	num Min = MIN3(R, G, B);
	num C = Max - Min;


	*V = Max;

	if(C > 0)
	{
		if(Max == R)
		{
			*H = (G - B) / C;

			if(G < B)
				*H += 6;
		}
		else if(Max == G)
			*H = 2 + (B - R) / C;
		else
			*H = 4 + (R - G) / C;

		*H *= 60;
		*S = C / Max;
	}
	else
		*H = *S = 0;
}
开发者ID:biotrump,项目名称:colorspace,代码行数:45,代码来源:colorspace.c


示例14: _find_subst_expressions_list

/* Find substrings matching .(expr), where expr is a balanced expression
 * (following R rules for matching [], (), {}, '', "", ``, %%, \, and comments.)
 * Returns a _list_ of _character arrays_ one array per each input string.
 * Each character array alternates between "outside quote" and "inside quote."
 */
SEXP _find_subst_expressions_list(SEXP strs, SEXP begin, SEXP end) {
  int ns, nb, ne;
  assert_type(strs, STRSXP);
  assert_type(begin, STRSXP);
  assert_type(end, STRSXP);
  ns = LENGTH(strs);
  nb = LENGTH(begin);
  ne = LENGTH(end);

  int nout;
  if (MIN3(ns, nb, ne) == 0) {
    nout = 0;
  } else {
    nout = MAX3(ns, nb, ne);
    if ((nout % ns > 0)||(nout % nb > 0)||(nout % ne > 0)) {
      warning("longer object length is not a multiple"
              " of shorter object length");
    }
  }

  SEXP out = PROTECT(allocVector(VECSXP, nout));
  if (ns == nout)
    setAttrib(out, R_NamesSymbol, getAttrib(strs, R_NamesSymbol));
  for (int i = 0; i < nout; i++) {
    SET_VECTOR_ELT(out, i,
                   find_subst_expressions(STRING_ELT(strs, i%ns),
                                          STRING_ELT(begin, i%nb),
                                          STRING_ELT(end, i%ne)));
  }

  UNPROTECT(1);
  return out;
}
开发者ID:crowding,项目名称:vadr,代码行数:38,代码来源:parse.c


示例15: getPhases

void
MSTrafficLightLogic::init(NLDetectorBuilder&) {
    const Phases& phases = getPhases();
    if (phases.size() > 1) {
        bool haveWarnedAboutUnusedStates = false;
        // warn about transistions from green to red without intermediate yellow
        for (int i = 0; i < (int)phases.size(); ++i) {
            const int iNext = (i + 1) % phases.size();
            const std::string& state1 = phases[i]->getState();
            const std::string& state2 = phases[iNext]->getState();
            assert(state1.size() == state2.size());
            if (!haveWarnedAboutUnusedStates && state1.size() > myLanes.size()) {
                WRITE_WARNING("Unused states in tlLogic '" + getID()
                              + "', program '" + getProgramID() + "' in phase " + toString(i)
                              + " after tl-index " + toString((int)myLanes.size() - 1));
                haveWarnedAboutUnusedStates = true;
            }
            for (int j = 0; j < (int)MIN3(state1.size(), state2.size(), myLanes.size()); ++j) {
                if ((LinkState)state2[j] == LINKSTATE_TL_RED
                        && ((LinkState)state1[j] == LINKSTATE_TL_GREEN_MAJOR
                            || (LinkState)state1[j] == LINKSTATE_TL_GREEN_MINOR)) {
                    for (LaneVector::const_iterator it = myLanes[j].begin(); it != myLanes[j].end(); ++it) {
                        if ((*it)->getPermissions() != SVC_PEDESTRIAN) {
                            WRITE_WARNING("Missing yellow phase in tlLogic '" + getID()
                                          + "', program '" + getProgramID() + "' for tl-index " + toString(j)
                                          + " when switching to phase " + toString(iNext));
                            return; // one warning per program is enough
                        }
                    }
                }
            }
        }
    }
}
开发者ID:RamonHPSilveira,项目名称:urbansim,代码行数:34,代码来源:MSTrafficLightLogic.cpp


示例16: rgb_to_hls

inline
void rgb_to_hls(float r, float g, float b, float &h, float &l, float &s) {
/* Given: r, b, g each in [0.1]
 * Desired: h in [0,360), l and s in [0,1]
 */

  float max = MAX3(r,g,b);
  float min = MIN3(r,g,b);
  l = (max+min)/2.0f;   /* This is lightness */
  /* Next calculate saturation */
  if (max == min) {   /* Achromatic, because r = g = b */
    s = 0.0f;
    h = 0.0f;       /* Actually: UNDEFINED */
  }
  else  {     /* Chromatic case */
    float delta = max-min;

    /* First calculate saturation */
    s = (l<=0.5f) ? (delta / (max+min)) : (delta / (2.0f - (max+min)));
    /* Next calculate the hue */
    if (r == max)
      h = (g-b)/delta;
    else if (g == max)
      h = 2.0f + (b-r)/delta;
    else if (b == max)
      h = 4.0f + (r-g)/delta;
    h *= 60.0f;
    if (h<0.0f)
      h += 360.0f;
  } /*Chromatic case */
} /* RGB_To_HLS */
开发者ID:sedillard,项目名称:ctvr,代码行数:31,代码来源:Color.hpp


示例17: RGBtoHSV

hsv_color RGBtoHSV(rgba_color rgb) {
	float min, max, delta;
	min = MIN3(rgb.r, rgb.g, rgb.b);
	max = MAX3(rgb.r, rgb.g, rgb.b);

	hsv_color ret;
	ret.a = rgb.a;

	ret.v = max;				// v
	delta = max - min;
	if (max != 0)
		ret.s = delta / max;		// s
	else {
		// r = g = b = 0		// s = 0, v is undefined
		ret.s = 0;
		ret.h = -1;
		return ret;
	}
	if (rgb.r == max)
		ret.h = (rgb.g - rgb.b) / delta;		// between yellow & magenta
	else if (rgb.g == max)
		ret.h = 2 + (rgb.b - rgb.r) / delta;	// between cyan & yellow
	else
		ret.h = 4 + (rgb.r - rgb.g) / delta;	// between magenta & cyan
	ret.h *= 60;				// degrees
	if (ret.h < 0)
		ret.h += 360;

	return ret;
}
开发者ID:Abscission,项目名称:platform-game,代码行数:30,代码来源:Utility.cpp


示例18: Rgb2Hsl

/**
 * @brief Convert an sRGB color to Hue-Saturation-Lightness (HSL)
 *
 * @param H, S, L pointers to hold the result
 * @param R, G, B the input sRGB values scaled in [0,1]
 *
 * This routine transforms from sRGB to the double hexcone HSL color space
 * The sRGB values are assumed to be between 0 and 1.  The outputs are
 *   H = hexagonal hue angle                (0 <= H < 360),
 *   S = { C/(2L)     if L <= 1/2           (0 <= S <= 1),
 *       { C/(2 - 2L) if L >  1/2
 *   L = (max(R',G',B') + min(R',G',B'))/2  (0 <= L <= 1),
 * where C = max(R',G',B') - min(R',G',B').  The inverse color transformation
 * is given by Hsl2Rgb.
 *
 * Wikipedia: http://en.wikipedia.org/wiki/HSL_and_HSV
 */
void Rgb2Hsl(num *H, num *S, num *L, num R, num G, num B)
{
	num Max = MAX3(R, G, B);
	num Min = MIN3(R, G, B);
	num C = Max - Min;


	*L = (Max + Min)/2;

	if(C > 0)
	{
		if(Max == R)
		{
			*H = (G - B) / C;

			if(G < B)
				*H += 6;
		}
		else if(Max == G)
			*H = 2 + (B - R) / C;
		else
			*H = 4 + (R - G) / C;

		*H *= 60;
		*S = (*L <= 0.5) ? (C/(2*(*L))) : (C/(2 - 2*(*L)));
	}
	else
		*H = *S = 0;
}
开发者ID:biotrump,项目名称:colorspace,代码行数:46,代码来源:colorspace.c


示例19: Rgb2Hf

void Rgb2Hf(float *H, float R, float G, float B)
{
	float Max = MAX3(R, G, B);
	float Min = MIN3(R, G, B);
	float C = Max - Min;

	if(C > 0)
	{
		if(Max == R)
		{
			*H = (G - B) / C;

			if(G < B)
				*H += 6;
		}
		else if(Max == G)
			*H = 2 + (B - R) / C;
		else
			*H = 4 + (R - G) / C;

		*H *= 60;
	}
	else
		*H = 0;
}
开发者ID:biotrump,项目名称:colorspace,代码行数:25,代码来源:colorspace.c


示例20: MIN2

SUMOReal
MSCFModel_SmartSK::moveHelper(MSVehicle* const veh, SUMOReal vPos) const {
    const SUMOReal oldV = veh->getSpeed(); // save old v for optional acceleration computation
    const SUMOReal vSafe = MIN2(vPos, veh->processNextStop(vPos)); // process stops
    // we need the acceleration for emission computation;
    //  in this case, we neglect dawdling, nonetheless, using
    //  vSafe does not incorporate speed reduction due to interaction
    //  on lane changing
    const SUMOReal vMin = getSpeedAfterMaxDecel(oldV);
    const SUMOReal vMax = MIN3(veh->getLane()->getVehicleMaxSpeed(veh), maxNextSpeed(oldV, veh), vSafe);
#ifdef _DEBUG
    if (vMin > vMax) {
        WRITE_WARNING("Vehicle's '" + veh->getID() + "' maximum speed is lower than the minimum speed (min: " + toString(vMin) + ", max: " + toString(vMax) + ").");
    }
#endif
    updateMyHeadway(veh);
    SSKVehicleVariables* vars = (SSKVehicleVariables*)veh->getCarFollowVariables();
#ifdef _DEBUG
    if (vars->ggOld.size() > 1) {
        std::cout << "# more than one entry in ggOld list. Speed is " << vPos << ", corresponding dist is " << vars->ggOld[(int) vPos] << "\n";
        for (std::map<int, SUMOReal>::iterator I = vars->ggOld.begin(); I != vars->ggOld.end(); I++) {
            std::cout << "# " << (*I).first << ' ' << (*I).second << std::endl;
        }
    }
#endif

    vars->gOld = vars->ggOld[(int) vPos];
    vars->ggOld.clear();
    return veh->getLaneChangeModel().patchSpeed(vMin, MAX2(vMin, dawdle(vMax)), vMax, *this);
}
开发者ID:p1tt1,项目名称:sumo,代码行数:30,代码来源:MSCFModel_SmartSK.cpp



注:本文中的MIN3函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ MINBPC函数代码示例发布时间:2022-05-30
下一篇:
C++ MIN2函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap