//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴 //Procedure GetWindDirVel //Author Craig Beeston //Date Thu 10 Jun 1999 // //Description Returns the wind speed and direction at a given altitude // //Inputs Alt // //Returns Wind Heading and Speed // //------------------------------------------------------------------------------ Bool Atmosphere::GetWindDirVel (SLong alt, SWord& hdg, SLong& speed) { if(!Save_Data.flightdifficulty [FD_WINDEFFECTS]) { hdg = 0; speed = 0; return(TRUE); } if(alt > 914400) // 30,000 ft { hdg = SWord(diralt * 182.04); //DeadCode RJS 16Dec99 speed = (51 * windalt) / 10; speed = SLong(5148. * windalt); //RJS 16Dec99 return(TRUE); } //DeadCode RJS 16Dec99 SWord Dir0 = SWord(182.04 * dir0); //DeadCode RJS 16Dec99 SWord DirAlt = SWord(182.04 * diralt); //DeadCode RJS 16Dec99 //DeadCode RJS 16Dec99 SWord DeltaDir = DirAlt - Dir0; FP Dir0 = 182.04 * dir0; //RJS 16Dec99 FP DirAlt = 182.04 * diralt; //RJS 16Dec99 FP DeltaDir = DirAlt - Dir0; //RJS 16Dec99 FP Fract = FP(alt) / 914411.0; FP fdir = Dir0 + Fract * DeltaDir; FP fspeed = ((1. - Fract) * wind0 + Fract * windalt) * 5148.;//RJS 16Dec99 hdg = SWord(fdir); speed = SLong(fspeed); return(TRUE); }
void TMissionEditor::MoveDrag(int x,int y) { PtPair b2p=dragline.b2; dragline.b2.x=x; dragline.b2.y=y; if (dragline.linear) { if ( Math_Lib.AbsSign(SLong(dragline.a.x-dragline.c.x)) > Math_Lib.AbsSign(SLong(dragline.a.y-dragline.c.y)) ) dragline.b2.y=dragline.a.y+ double(dragline.b2.x-dragline.a.x) *(dragline.c.y-dragline.a.y) /(dragline.c.x-dragline.a.x); else dragline.b2.x=dragline.a.x+ double(dragline.b2.y-dragline.a.y) *(dragline.c.x-dragline.a.x) /(dragline.c.y-dragline.a.y); } PushScreenDrag(dragline.b2); InvalidateLine(dragline.a,dragline.b2); InvalidateLine(dragline.c,dragline.b2); InvalidateLine(dragline.a,b2p); InvalidateLine(dragline.c,b2p); InvalidateBox(dragline.b2,dragline.bw); InvalidateBox(b2p,dragline.bw); }
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴 //Procedure CheckTri //Author Paul. //Date Mon 1 Jun 1998 //------------------------------------------------------------------------------ bool CheckTri(int pntCnt,UByte* polyDef,PntDef* pntArray,int p0,int p1,int p2) { const bool INSIDE=false; const bool OUTSIDE=true; UByte i0=polyDef[p0]; UByte i1=polyDef[p1]; UByte i2=polyDef[p2]; PntDef& pt0=pntArray[i0]; PntDef& pt1=pntArray[i1]; PntDef& pt2=pntArray[i2]; SLong vi,vj,wi,wj; vi=SLong(pt1.x)-SLong(pt0.x); vj=SLong(pt1.z)-SLong(pt0.z); wi=SLong(pt1.x)-SLong(pt2.x); wj=SLong(pt1.z)-SLong(pt2.z); if (vi*wj>=wi*vj) return false; //failed on crossproduct test //check that no other active points in the poly are contained //within this new triangle for (int x=(p2+1)%pntCnt;x!=p0;++x%=pntCnt) { UByte it=polyDef[x]; if (it!=i0&&it!=i1&&it!=i2) { SWord ptx=pntArray[it].x; SWord ptz=pntArray[it].z; SWord x0,y0,x1,y1,x2,y2; x0=SWord(pt0.x)-ptx; y0=SWord(pt0.z)-ptz; //if the test point matches vertex 0 return false (inside) if (x0==0 && y0==0) return false; x1=SWord(pt1.x)-ptx; y1=SWord(pt1.z)-ptz; //if the test point matches vertex 1 return false (inside) if (x1==0 && y1==0) return false; x2=SWord(pt2.x)-ptx; y2=SWord(pt2.z)-ptz; //if the test point matches vertex 2 return false (inside) if (x2==0 && y2==0) return false; //if all points are to the left of the test point then no more //checks are required for this test point if (!(x0>0 && x1>0 && x2>0)) { if (x0>0 || x1>0 || x2>0) { SWord count; //if any of the triangle sides are horizontal and at the //same y as the test point then return false (inside) if //the test point lies between the sides endpoints if ((count=(y0==0)+(y1==0))==2 && (x0^x1)<0) return false; else if (count && (count=(y1==0)+(y2==0))==2 && (x1^x2)<0) return false; else if (count && (count=(y2==0)+(y0==0))==2 && (x2^x0)<0) return false; else if (!y0) { if ((y1^y2)<0) return false; } else if (!y1) { if ((y2^y0)<0) return false; } else if (!y2) { if ((y0^y1)<0) return false; } else { count=0; //test for intersection of segment v0->v1 if ((y0^y1)<0) { if ((x0^x1)<0) { SLong yiy0=SLong(-y0)<<16; SLong x1x0=SLong(x1-x0)<<16; SLong y1y0=SLong(y1-y0)<<16; SLong res=MULDIVSIN(yiy0,x1x0,y1y0)+(x0<<16); //point is classified as inside if it is on the line if (!((res+0x7F)&0xFFFFFF00)) return false; if (res>0) count++; //cross over detected } else count++; //cross over detected } if ((y1^y2)<0) { if ((x1^x2)<0) { SLong yiy1=SLong(-y1)<<16; SLong x2x1=SLong(x2-x1)<<16; SLong y2y1=SLong(y2-y1)<<16; SLong res=MULDIVSIN(yiy1,x2x1,y2y1)+(x1<<16); //point is classified as inside if it is on the line if (!((res+0x7F)&0xFFFFFF00)) return false; if (res>0) count++; //cross over detected } else count++; //cross over detected } //if count is 2 then there's no need to do the final //test because the test ray cannot intersect more than //2 sides of the triangle if (count!=2) { if ((y2^y0)<0) { if ((x2^x0)<0) { SLong yiy2=SLong(-y2)<<16; SLong x0x2=SLong(x0-x2)<<16; SLong y0y2=SLong(y0-y2)<<16; SLong res=MULDIVSIN(yiy2,x0x2,y0y2)+(x2<<16); //point is classified as inside if it is on the line if (!((res+0x7F)&0xFFFFFF00)) return false; if (res>0) count++; //cross over detected } else count++; //cross over detected } //even number of crossings means the point is outside //the triangle. odd number means the point is inside if (count&1) return false; } } } else if (x0==0 && x1==0) { if ((y0^y1)<0) return false; } else if (x1==0 && x2==0) { if ((y1^y2)<0) return false; } else if (x2==0 && x0==0) { if ((y2^y0)<0) return false; } } } } return true; }