本文整理汇总了C++中MAX3函数的典型用法代码示例。如果您正苦于以下问题:C++ MAX3函数的具体用法?C++ MAX3怎么用?C++ MAX3使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MAX3函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: itemAnimationTime
double itemAnimationTime(LWItemID item, int *keys)
{
double t = 0.0;
LWChannelID chan[3];
int k[3]={0,0,0}, typ;
LWDVector tim;
VCLR(tim);
typ = itemInfo->type(item);
k[0] = itemKeys(item, LWIP_POSITION, chan,tim);
k[1] = itemKeys(item, LWIP_ROTATION, chan,tim+1);
if(typ==LWI_OBJECT)
k[2] = itemKeys(item, LWIP_SCALING, chan,tim+2);
else if(typ==LWI_LIGHT)
{
LWEnvelopeID intens;
lightIntensity(item,0.0,&intens);
if(intens)
tim[2] = envDuration(intens, &(k[2]));
k[2] += 2; // catch up to 3-channel types
}
t = MAX3(tim[0],tim[1],tim[2]);
if(keys)
*keys = MAX3(k[0],k[1],k[2]);
return t;
}
示例2: compare_boxes
int compare_boxes(BBOX &box1, BBOX &box2)
{
double tol_x, tol_y, tol_z;
tol_x = 0.01*MAX3( ABS(box1.x_max-box1.x_min), ABS(box2.x_max-box2.x_min), 1. );
tol_y = 0.01*MAX3( ABS(box1.y_max-box1.y_min), ABS(box2.y_max-box2.y_min), 1. );
tol_z = 0.01*MAX3( ABS(box1.z_max-box1.z_min), ABS(box2.z_max-box2.z_min), 1. );
// tol_x = tol_y = tol_z = 0.;
if ( (box1.x_min - box2.x_max) > tol_x ) return(0); // Return 0 if no overlap
if ( (box2.x_min - box1.x_max) > tol_x ) return(0);
if ( (box1.y_min - box2.y_max) > tol_y ) return(0);
if ( (box2.y_min - box1.y_max) > tol_y ) return(0);
if ( (box1.z_min - box2.z_max) > tol_z ) return(0);
if ( (box2.z_min - box1.z_max) > tol_z ) return(0);
return(1); // Boxes overlap
}
示例3: 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
}
示例4: MAX3
bool
NBRampsComputer::fulfillsRampConstraints(
NBEdge* potHighway, NBEdge* potRamp, NBEdge* other, SUMOReal minHighwaySpeed, SUMOReal maxRampSpeed) {
// do not build ramps on rail edges
if (isRailway(potHighway->getPermissions()) || isRailway(potRamp->getPermissions())) {
return false;
}
// do not build ramps on connectors
if (potHighway->isMacroscopicConnector() || potRamp->isMacroscopicConnector() || other->isMacroscopicConnector()) {
return false;
}
// check whether a lane is missing
if (potHighway->getNumLanes() + potRamp->getNumLanes() <= other->getNumLanes()) {
return false;
}
// check conditions
// is it really a highway?
SUMOReal maxSpeed = MAX3(potHighway->getSpeed(), other->getSpeed(), potRamp->getSpeed());
if (maxSpeed < minHighwaySpeed) {
return false;
}
/*
if (potHighway->getSpeed() < minHighwaySpeed || other->getSpeed() < minHighwaySpeed) {
return false;
}
*/
// is it really a ramp?
if (maxRampSpeed > 0 && maxRampSpeed < potRamp->getSpeed()) {
return false;
}
return true;
}
示例5: nextSegment
void
MELoop::checkCar(MEVehicle* veh) {
const SUMOTime leaveTime = veh->getEventTime();
MESegment* const onSegment = veh->getSegment();
MESegment* const toSegment = nextSegment(onSegment, veh);
const bool teleporting = (onSegment == 0); // is the vehicle currently teleporting?
if (changeSegment(veh, leaveTime, toSegment, teleporting)) {
return;
}
if (MSGlobals::gTimeToGridlock > 0 && veh->getWaitingTime() > MSGlobals::gTimeToGridlock && !veh->isStopped()) {
teleportVehicle(veh, toSegment);
return;
}
if (veh->getBlockTime() == SUMOTime_MAX) {
veh->setBlockTime(leaveTime);
}
if (leaveTime < toSegment->getEntryBlockTime()) {
// receiving segment has recently received another vehicle
veh->setEventTime(toSegment->getEntryBlockTime());
} else if (toSegment->hasSpaceFor(veh, leaveTime) && !veh->mayProceed()) {
// either the junction is blocked or the traffic light is red
veh->setEventTime(leaveTime + MAX2(SUMOTime(1), myLinkRecheckInterval));
} else {
SUMOTime newEventTime = MAX3(toSegment->getEventTime() + 1, leaveTime + 1, leaveTime + myFullRecheckInterval);
if (MSGlobals::gTimeToGridlock > 0) {
// if teleporting is enabled, make sure we look at the vehicle when the the gridlock-time is up
newEventTime = MIN2(newEventTime, veh->getBlockTime() + MSGlobals::gTimeToGridlock + 1);
}
veh->setEventTime(newEventTime);
}
addLeaderCar(veh, onSegment->getLink(veh));
}
示例6: 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 */
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: 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;
}
示例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;
}
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;
}
示例13: MAX3
void
MSPerson::MSPersonStage_Waiting::proceed(MSNet* net, MSTransportable* person, SUMOTime now, Stage* previous) {
previous->getEdge()->addPerson(person);
myWaitingStart = now;
const SUMOTime until = MAX3(now, now + myWaitingDuration, myWaitingUntil);
net->getPersonControl().setWaitEnd(until, person);
}
示例14: rgb_to_hsv
struct hsv_color rgb_to_hsv(struct rgb_color rgb) {
struct hsv_color hsv;
unsigned char rgb_min, rgb_max;
rgb_min = MIN3(rgb.r, rgb.g, rgb.b);
rgb_max = MAX3(rgb.r, rgb.g, rgb.b);
hsv.val = rgb_max;
if (hsv.val == 0) {
hsv.hue = hsv.sat = 0;
return hsv;
}
hsv.sat = 255*long(rgb_max - rgb_min)/hsv.val;
if (hsv.sat == 0) {
hsv.hue = 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);
}
return hsv;
}
示例15: _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;
}