bool fft(int n, double *wave, double *mag, double *phase) { int i, n2 = n/2; double n_2 = ((double)n)/2.0; double *x; fftw_plan p; x = fftw_malloc(n*sizeof(double)); if (!x) return false; p = fftw_plan_r2r_1d(n, x, x, FFTW_R2HC, FFTW_ESTIMATE); if (!p) { fftw_free(x); return false; } memcpy(x, wave, n*sizeof(double)); fftw_execute(p); mag[0] = myabs(x[0], 0.0)/n; phase[0] = myarg(x[0], 0.0); for (i = 1; i < n2; i++) { mag[i] = myabs(x[i], x[n-i])/n_2; phase[i] = myarg(x[i], x[n-i]); } if (n > 1) if (n%2 == 0) { mag[n2] = myabs(x[n2], 0.0)/n; phase[n2] = myarg(x[n2], 0.0); } else { mag[n2] = myabs(x[n2], x[n-n2])/n_2; phase[n2] = myarg(x[n2], x[n-n2]); } fftw_destroy_plan(p); fftw_free(x); return true; }
Uint32 move_ball(Uint32 interval, void * param) { struct ball * the_ball = (struct ball *) param; SDL_Rect clear_rect; clear_rect.x = the_ball->x; clear_rect.y = the_ball->y; clear_rect.w = the_ball->ball_bmp->w; clear_rect.h = the_ball->ball_bmp->h; SDL_FillRect( the_ball->screen, &clear_rect, 0 ); SDL_UpdateRect(the_ball->screen, the_ball->x, the_ball->y, the_ball->ball_bmp->w, the_ball->ball_bmp->h); if( myabs(the_ball->x - the_ball->destx) > myabs(the_ball->dx) ) the_ball->x += the_ball->dx; if( myabs(the_ball->y - the_ball->desty) > myabs(the_ball->dy) ) the_ball->y += the_ball->dy; SDL_Rect whereTo; whereTo.x=the_ball->x; whereTo.y=the_ball->y; whereTo.w=the_ball->ball_bmp->w; whereTo.h=the_ball->ball_bmp->h; if(SDL_BlitSurface(the_ball->ball_bmp, NULL, the_ball->screen, &whereTo) < 0) fprintf(stderr, "BlitSurface error: %sn", SDL_GetError()); SDL_UpdateRect(the_ball->screen, the_ball->x, the_ball->y, the_ball->ball_bmp->w, the_ball->ball_bmp->h); return interval; }
void dfs(int x, int y, int d) { int tx, ty, i; if(x == edx && y == edy) { if((stx == edx && myabs(sty - edy) == 1) || (sty == edy && myabs(stx - edx) == 1)) { if(cnt == 1) return; } if(max > cnt) max = cnt; return; } for(i = 0;i < 4; i++) { tx = x + dx[i]; ty = y + dy[i]; if(check(tx, ty)) { if(d != -1 && d != i) cnt++; if(cnt > max) { cnt--; continue;} visited[x][y] = 1; dfs(tx, ty, i); visited[x][y] = 0; if(d != -1 && d != i) cnt--; } } }
void main() { allegrosetup(scrwid,scrhei); makesplitpalette(&redtowhitepalette,&greentowhitepalette); randomise(); PPsetup(scrwid,scrhei,4); JBmp j=JBmp(scrwid,scrhei); j.clear(); List<Part> ps=List<Part>(); for (int i=1;i<=numparts/line;i++) { newparts(&ps); } int frame=0; do { for (int i=1;i<=ps.len;i++) { Part *p=ps.p2num(i); int sx,sy; PPgetscrpos(p->pos,&sx,&sy); int sxb,syb; PPgetscrpos(p->pos+V3d(p->rad,0,0),&sxb,&syb); float rad=sqrt(mysquare(sx-sxb)+mysquare(sy-syb)); j.filledcirclenodarker(sx,sy,rad,p->outc); j.filledcirclenodarker(sx,sy,rad/3,p->inc); // j.shadedcirclenodarker(sx,sy,rad,p->inc,p->outc); } for (int x=0;x<scrwid;x++) for (int y=0;y<scrhei;y++) { int k=j.bmp[y][x]; if (k>=128+fade) j.bmp[y][x]-=fade; else if (k<128) if (k>=fade) j.bmp[y][x]-=fade; // j.bmp[y][x]=intchop(k-fade,0,128); // j.bmp[y][x]=128+intchop(k-fade-128,0,128); if (k>=128 && k<=128+3) j.bmp[y][x]=0; } j.writetoscreen(); Matrix m,n; V3d rotaxis=V3d::rotate(V3d(0,1,0),V3d(0,0,1),pi/4.0*sin(2*pi*frame/2000)); m.makerotation(rotaxis,pi/1000.0); n.makerotation(rotaxis,-pi/1000.0); for (int i=1;i<=ps.len;i++) { Part *p=ps.p2num(i); if (p->sgn>0) p->pos=m*p->pos; else p->pos=n*p->pos; p->pos=p->pos+V3d(0,0,-0.03); if ((p->pos.z<-4 || max(myabs(p->pos.x),myabs(p->pos.y))>2)) { ps.removenum(i); if (ps.len<numparts-line) newparts(&ps); } } frame++; } while (!key[KEY_ESC]); }
int main() { std::cout << "-10 の絶対値" << myabs(-10) << std::endl; std::cout << "-10L の絶対値" << myabs(-10L) << std::endl; std::cout << "-10.01 の絶対値" << myabs(-10.01) << std::endl; return 0; }
void GetScaledLRect (LongRect *CurrRectPtr, double XToYRatio, LongRect *LimitRectPtr, long XMargin, long YMargin) /* this subroutine is the same as GetScaledRect except for LongRects */ /* Warning: this subroutine assumes a top greater than bottom */ /* Scaled rectangle replaces CurrRect */ /* Note: current sizes do not reflect the margins to be configured by subroutine */ /* Note: the top and left coordinates of the LimitRect are used only to calculate the maximum Delta X and Y, and have to absolute relevence */ { long DeltaX, DeltaY, MaxDeltaX, MaxDeltaY, ScaledDX, ScaledDY; LongRect ScaledRect; DeltaX = CurrRectPtr -> right - CurrRectPtr -> left; DeltaY = CurrRectPtr -> top - CurrRectPtr -> bottom; ScaledDX = DeltaX * XToYRatio; ScaledDY = DeltaY / XToYRatio; MaxDeltaX = LimitRectPtr -> right - LimitRectPtr -> left - XMargin; MaxDeltaY = LimitRectPtr -> top - LimitRectPtr -> bottom - YMargin; /* printf (" DeltaX = %hd DeltaY = %hd\n", DeltaX, DeltaY); printf ("MaxDeltaX = %hd MaxDeltaY = %hd\n", MaxDeltaX, MaxDeltaY);*/ /* if DeltaX is greater than DeltaY use DeltaX to calculate scaled DeltaY */ // if (sabs (ScaledDX) > sabs (ScaledDY)) if (myabs(ScaledDX) > myabs(ScaledDY)) { ScaledRect = *CurrRectPtr; ScaledRect.top = CurrRectPtr -> bottom + DeltaX / XToYRatio; } else { ScaledRect = *CurrRectPtr; ScaledRect.right = CurrRectPtr -> left + DeltaY * XToYRatio; } /* printf ("ScaledRect before limit check = "); printfRect (&ScaledRect);*/ /* now check to see if we are going beyond allowd limits set by LimitRect */ if ((ScaledRect.right - ScaledRect.left > MaxDeltaX) || (ScaledRect.top - ScaledRect.bottom > MaxDeltaY)) { ScaledRect.right = ScaledRect.left + MaxDeltaX; ScaledRect.top = ScaledRect.bottom + MaxDeltaX / XToYRatio; if (ScaledRect.top - ScaledRect.bottom > MaxDeltaY) { ScaledRect.top = ScaledRect.bottom + MaxDeltaY; ScaledRect.right = ScaledRect.left + MaxDeltaY * XToYRatio; } } /* printfRect (&ScaledRect);*/ *CurrRectPtr = ScaledRect; return; }
int main(){ int min; int k; int t, s; char buf[100]; scanf("%d",&k); gets(buf); for(int t=1;t<=k;t++){ buf[0] = '\0'; gets(buf); int num = 0; n = 0; for(int i=0; buf[i]; i++){ if(buf[i] >= '0' && buf[i] <= '9') num = num*10 + (buf[i] - '0'); else if(buf[i] == ' '){ m[n++] = num; num = 0; } } m[n++] = num; int sum = 0; for(int i=0;i<n;i++){ sum += m[i]; } q[0] = 0; vis[0] = t; nq = 1; min = (1<<30); for(int i=0; i<n; i++){ for(int j=nq-1; j>=0; j--){ s = q[j] + m[i]; if(myabs((s - (sum-s))) < min) min = myabs(s - (sum-s)); if(vis[s] != t){ vis[s] = t; q[nq++] = s; } } } if(min == 0) printf("YES\n"); else printf("NO\n"); } return 0; }
float furthest(V2d lori) { V2d ctr=centroid; float len=0; for (int i=1;i<=bpixs.len;i++) { float d=V2d::dot(lori,V2d(bpixs.num(i))-ctr); if (myabs(d)>len) len=myabs(d); } return len; }
} DONE #include <iostream> int main() { std::cout << myabs(9.0) << '\n'; std::cout << myabs(16.0) << '\n'; std::cout << myabs(-8.0) << '\n'; return 0; }
float Correlator::length() { V2d ctr=centroid(); V2d lori=ori(); float len=0; for (int i=1;i<=xs.len;i++) { float d=V2d::dot(lori,V2d(xs.num(i),ys.num(i))-ctr); if (myabs(d)>len) len=myabs(d); } return len; }
// Not compensated for weighting float Correlator::fatness() { V2d ctr=centroid(); V2d lori=ori().perp().norm(); float fat=0; for (int i=1;i<=xs.len;i++) { float d=V2d::dot(lori,V2d(xs.num(i),ys.num(i))-ctr); if (myabs(d)>fat) fat=myabs(d); } return fat; }
void main() { allegrosetup(scrwid,scrhei); makesplitpalette(&redtowhitepalette,&greentowhitepalette); PPsetup(scrwid,scrhei,4); JBmp j=JBmp(scrwid,scrhei); j.clear(); List<Part> ps=List<Part>(); for (int i=1;i<=10;i++) { Part p; newpart(&p); ps+p; } int frame=0; do { for (int i=1;i<=ps.len;i++) { Part *p=ps.p2num(i); int sx,sy; PPgetscrpos(p->pos,&sx,&sy); int sxb,syb; PPgetscrpos(p->pos+V3d(p->rad,0,0),&sxb,&syb); float rad=sqrt(mysquare(sx-sxb)+mysquare(sy-syb)); j.filledcircle(sx,sy,rad,p->inc); // j.filledcirclenodarker(sx,sy,rad/3,p->inc); } for (int x=0;x<scrwid;x++) for (int y=0;y<scrhei;y++) { int k=j.bmp[y][x]; if (k==128) j.bmp[y][x]=0; if (k<128) j.bmp[y][x]=chop(k-4,0,128); else j.bmp[y][x]=128+chop(k-4-128,0,128); } j.writetoscreen(); Matrix m,n; V3d rotaxis=V3d::rotate(V3d(0,1,0),V3d(0,0,1),pi/4.0*sin(2*pi*frame/4000)); m.makerotation(rotaxis,pi/1000.0); n.makerotation(rotaxis,-pi/1000.0); for (int i=1;i<=ps.len;i++) { Part *p=ps.p2num(i); if (p->sgn>0) p->pos=m*p->pos; else p->pos=n*p->pos; p->pos=p->pos+V3d(0,0,-0.03); if (p->pos.z<-4 || max(myabs(p->pos.x),myabs(p->pos.y))>2) newpart(p); } frame++; } while (!key[KEY_ESC]); }
Uint32 move_ball(Uint32 interval, void * param) { struct ball * the_ball = (struct ball *) param; if( myabs(the_ball->x - the_ball->destx) > myabs(the_ball->dx) ) the_ball->x += the_ball->dx; if( myabs(the_ball->y - the_ball->desty) > myabs(the_ball->dy) ) the_ball->y += the_ball->dy; render_ball(the_ball); return interval; }
int main() { long i,l; double n,m,x,y,s,xx1,xx2,yy1,yy2,d; scanf("%lf%lf",&m,&n); s=n*m; scanf("%ld",&l); for (i=1;i<=l;i++) { scanf("%lf%lf",&x,&y); if (myabs(y)<1.0) { d=sqrt(1.0-y*y); xx1=x-d; xx2=x+d; if (xx1<0) xx1=0; if (xx2>n) xx2=n; s-=((xx2-xx1)*y/2.0); } if (myabs(m-y)<1.0) { d=sqrt(1.0-(m-y)*(m-y)); xx1=x-d; xx2=x+d; if (xx1<0) xx1=0; if (xx2>n) xx2=n; s-=((xx2-xx1)*(m-y)/2.0); } if (myabs(x)<1.0) { d=sqrt(1.0-x*x); yy1=y-d; yy2=y+d; if (yy1<0) yy1=0; if (yy2>m) yy2=m; s-=((yy2-yy1)*x/2.0); } if (myabs(n-x)<1.0) { d=sqrt(1.0-(n-x)*(n-x)); yy1=y-d; yy2=y+d; if (yy1<0) yy1=0; if (yy2>m) yy2=m; s-=((yy2-yy1)*(n-x)/2.0); } } printf("%.10lf\n",s); return 0; }
static Uint64 calculate( size_t size, size_t vertexCount, const dataType* data ) { const dataType* v = data; Uint64 total = 0; for (size_t i = 0; (i + 1) < vertexCount; i += 2, v += 2 * size) { total += Uint64(std::max(myabs(v[0] - v[size]), myabs(v[1] - v[size + 1]))); } return total; }
void movepart(int i) { plotpart(i,0); part[i].vel.x=part[i].vel.x+floatrnd(-brownian,brownian); part[i].vel.y=part[i].vel.y+floatrnd(-brownian,brownian); part[i].vel.z=part[i].vel.z+floatrnd(-brownian,brownian); part[i].pos=V3dadd(part[i].pos,part[i].vel); if (myabs(part[i].pos.x)>1) part[i].vel.x=-part[i].vel.x; if (myabs(part[i].pos.y)>1) part[i].vel.y=-part[i].vel.y; if (myabs(part[i].pos.z)>1) part[i].vel.z=-part[i].vel.z; plotpart(i,255); }
float linedist() { if (type!=Paragraph && type!=Block) printf("Line distance requested but not a paragraph!\n"); sortdir=lineori().perp(); // Will sort them in order of this direction if (sortdir.y<0) sortdir=-sortdir; // Point downwards lines.sort(&sortfn); float best=0; for (int i=1;i<=lines.len-1;i++) { float f=linedist(i); if (myabs(f)>best) best=myabs(f); } return best; }
/************************************************************************** 函数功能:转向PD控制 入口参数:左轮编码器、右轮编码器、Z轴陀螺仪 返回 值:转向控制PWM 作 者:平衡小车之家 **************************************************************************/ int turn(int encoder_left,int encoder_right,float gyro)//转向控制 { static float Turn_Target,Turn,Encoder_temp,Turn_Convert=0.9,Turn_Count; float Turn_Amplitude=88/Flag_sudu,Kp=42,Kd=0; //=============遥控左右旋转部分=======================// if(1==Flag_Left||1==Flag_Right) //这一部分主要是根据旋转前的速度调整速度的起始速度,增加小车的适应性 { if(++Turn_Count==1) Encoder_temp=myabs(encoder_left+encoder_right); Turn_Convert=50/Encoder_temp; if(Turn_Convert<0.6)Turn_Convert=0.6; if(Turn_Convert>3)Turn_Convert=3; } else { Turn_Convert=0.9; Turn_Count=0; Encoder_temp=0; } if(1==Flag_Left) Turn_Target-=Turn_Convert; else if(1==Flag_Right) Turn_Target+=Turn_Convert; else Turn_Target=0; if(Turn_Target>Turn_Amplitude) Turn_Target=Turn_Amplitude; //===转向速度限幅 if(Turn_Target<-Turn_Amplitude) Turn_Target=-Turn_Amplitude; if(Flag_Qian==1||Flag_Hou==1) Kd=1; else Kd=0; //转向的时候取消陀螺仪的纠正 有点模糊PID的思想 //=============转向PD控制器=======================// Turn=-Turn_Target*Kp -gyro*Kd; //===结合Z轴陀螺仪进行PD控制 return Turn; }
string nexusIC(int i,Pr* pr,Node** nodes,double* T_min,double* T_max){ ostringstream b,date; if (i>0){ b<<nodes[i]->B; } date<<nodes[i]->D; if (i>=pr->nbINodes && nodes[i]->type=='p') return nodes[i]->L+"[&date="+date.str()+"]:"+b.str(); else{ ostringstream tmin,tmax; tmin<< T_min[i]; tmax<< T_max[i]; if (i>=pr->nbINodes) { return nodes[i]->L+"[&date="+date.str()+"][&CI=\""+date.str()+"("+tmin.str()+","+tmax.str()+")\"]:"+b.str(); } else{ string newLabel="("; for (vector<int>::iterator iter=nodes[i]->suc.begin(); iter!=nodes[i]->suc.end(); iter++) { int s = *iter; string l=nexusIC(s,pr,nodes,T_min,T_max); if (iter==nodes[i]->suc.begin()) newLabel+=l; else newLabel+=","+l; } if (i>0) { if (myabs(nodes[i]->B)>toCollapse) return newLabel+")"+nodes[i]->L+"[&date="+date.str()+"][&CI=\""+date.str()+"("+tmin.str()+","+tmax.str()+")\"]:"+b.str(); else return newLabel+")"+nodes[i]->L+":"+b.str(); } else{ return newLabel+")"+nodes[i]->L+"[&date="+date.str()+"][&CI=\""+date.str()+"("+tmin.str()+","+tmax.str()+")\"];\n"; } } } }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){ /*entry: A, pvt*/ /*out: A, pvt*/ double *Ain, *A; double *pvtin, *pvt; int M,N, i, j, k, tmp; int maxind; double max, tmpd=0; /*mxget*/ Ain = mxGetPr(prhs[0]); N = mxGetN(prhs[0]); pvtin = mxGetPr(prhs[1]); plhs[0] = mxCreateDoubleMatrix(N,N,mxREAL); plhs[1] = mxCreateDoubleMatrix(1,N,mxREAL); A = mxGetPr(plhs[0]); pvt = mxGetPr(plhs[1]); /*copy*/ copy(A, Ain, N, N); copy(pvt, pvtin, 1, N); for (i=0;i<N;i++) { maxind=i; max=myabs(A[i*N+i]); for (j=i+1;j<N;j++) { if (myabs(A[i*N+j])>max) { maxind=j; max=myabs(A[i*N+j]); } } if (max==0) { mexPrintf("LUfactoration failed: coefficient matrix is singular"); return 0; } else { if (maxind != i) { tmpd = pvt[i]; pvt[i] = pvt[maxind]; pvt[maxind]=tmpd; exchangerow(A, N, i, maxind); } } for (j=i+1;j<N;j++) { A[i*N+j] = A[i*N+j]/A[i*N+i]; for (k=i+1;k<N;k++) { A[k*N+j] = A[k*N+j] - A[i*N+j] * A[k*N+i]; } } } }
void CDSMMuxerFilter::MuxPacket(IBitStream* pBS, const MuxerPacket* pPacket) { if (pPacket->IsEOS()) { return; } if (pPacket->pPin->CurrentMediaType().majortype == MEDIATYPE_Text) { CStringA str((char*)pPacket->pData.GetData(), (int)pPacket->pData.GetCount()); str.Replace("\xff", " "); str.Replace(" ", " "); str.Replace(" ", " "); str.Trim(); if (str.IsEmpty()) { return; } } ASSERT(!pPacket->IsSyncPoint() || pPacket->IsTimeValid()); REFERENCE_TIME rtTimeStamp = _I64_MIN, rtDuration = 0; int iTimeStamp = 0, iDuration = 0; if (pPacket->IsTimeValid()) { rtTimeStamp = pPacket->rtStart; rtDuration = max(pPacket->rtStop - pPacket->rtStart, 0); iTimeStamp = GetByteLength(myabs(rtTimeStamp)); ASSERT(iTimeStamp <= 7); iDuration = GetByteLength(rtDuration); ASSERT(iDuration <= 7); IndexSyncPoint(pPacket, pBS->GetPos()); } UINT64 len = 2 + iTimeStamp + iDuration + pPacket->pData.GetCount(); // id + flags + data MuxPacketHeader(pBS, DSMP_SAMPLE, len); pBS->BitWrite(pPacket->pPin->GetID(), 8); pBS->BitWrite(pPacket->IsSyncPoint(), 1); pBS->BitWrite(rtTimeStamp < 0, 1); pBS->BitWrite(iTimeStamp, 3); pBS->BitWrite(iDuration, 3); pBS->BitWrite(myabs(rtTimeStamp), iTimeStamp << 3); pBS->BitWrite(rtDuration, iDuration << 3); pBS->ByteWrite(pPacket->pData.GetData(), (int)pPacket->pData.GetCount()); }
inline SCALAR dsign(SCALAR s) { SCALAR abs_s = myabs(s); if (abs_s==SCALAR(0.0)) { throw std::runtime_error("dsign: s must not be zero"); } else { return s/abs_s; } }
bool equals(double a, double b) { if (myabs(a-b) < EXP) { return true; } return false; }
/************************************************************************** 函数功能:赋值给PWM寄存器 入口参数:左轮PWM、右轮PWM 返回 值:无 **************************************************************************/ void Set_Pwm(int moto1,int moto2,int moto3,int moto4) { static int HismotoA = 0; static int HismotoB = 0; static int HismotoC = 0; static int HismotoD = 0; PWMA= (1-flterLambda)*HismotoA + flterLambda* myabs(moto1); PWMB= (1-flterLambda)*HismotoB + flterLambda* myabs(moto2); PWMC= (1-flterLambda)*HismotoC + flterLambda* myabs(moto3); PWMD= (1-flterLambda)*HismotoD + flterLambda* myabs(moto4); HismotoA = PWMA; HismotoB = PWMB; HismotoC = PWMC; HismotoD = PWMD; }
int match(int at,short int *wav,int len) { int i,ok=0; for(i=0;i<len;i++) { if(myabs(wav[i]-wave[i+at])<305) ok++; if(ok/(i+1.)<.5) return 0; } return 1; }
void Corner::findnormal() { normal=V3d::o; for (int i=1;i<=gs.len;i++) normal=normal+gs.num(i)->normal(); if (gs.len>0) normal.normalise(); col=ucharchop(255*myabs(V3d::normdot(normal,V3d(-1,2,-1)))); // col=col*(float)gs.len/6.0; }
int merge(uchar x,uchar y,float amount) { int d=myabs(y-x); int s=mysgn(y-x); if (d>128) { d=256-d; s=-s; } return (uchar)(x+s*d*amount); }
virtual void evolve() { pos=pos+vel; hang(&pos,V2d(scrwid/2,scrhei/2),0.99,0); vel=hang(vel,V2d::o,0.99,0.3); hang(&radvel,0,0.995,0.2); radvel=myabs(radvel); rad+=radvel; hang(&rad,40,0.97); }
void CDSMMuxerFilter::MuxFooter(IBitStream* pBS) { // syncpoints int len = 0; CAtlList<IndexedSyncPoint> isps; REFERENCE_TIME rtPrev = 0, rt; UINT64 fpPrev = 0, fp; POSITION pos = m_isps.GetHeadPosition(); while (pos) { IndexedSyncPoint& isp = m_isps.GetNext(pos); TRACE(_T("sp[%d]: %I64d %I64x\n"), isp.id, isp.rt, isp.fp); rt = isp.rt - rtPrev; rtPrev = isp.rt; fp = isp.fp - fpPrev; fpPrev = isp.fp; IndexedSyncPoint isp2; isp2.fp = fp; isp2.rt = rt; isps.AddTail(isp2); len += 1 + GetByteLength(myabs(rt)) + GetByteLength(fp); // flags + rt + fp } MuxPacketHeader(pBS, DSMP_SYNCPOINTS, len); pos = isps.GetHeadPosition(); while (pos) { IndexedSyncPoint& isp = isps.GetNext(pos); int irt = GetByteLength(myabs(isp.rt)); int ifp = GetByteLength(isp.fp); pBS->BitWrite(isp.rt < 0, 1); pBS->BitWrite(irt, 3); pBS->BitWrite(ifp, 3); pBS->BitWrite(0, 1); // reserved pBS->BitWrite(myabs(isp.rt), irt << 3); pBS->BitWrite(isp.fp, ifp << 3); } }
Uint64 getTriangleArea(gmtl::Vec<dataType, 2> a, gmtl::Vec<dataType, 2> b, gmtl::Vec<dataType, 2> c ) { // http://www.btinternet.com/~se16/hgb/triangle.htm float ab = b[0] * a[1] - a[0] * b[1]; float bc = c[0] * b[1] - b[0] * c[1]; float ac = a[0] * c[1] - c[0] * a[1]; return Uint64(myabs(ab + bc + ac) / 2); }