void Eirika::draw() { Drawable::draw(); Sphere(Point3(location,terrainMap->getHeight(location) + 1.5), radius, teal).draw(); Circle(Point3(location,terrainMap->getHeight(location) + .1), radius, black).draw(); }
TEST(Circle, Projection){ ASSERT_EQ(Segment(2.5,2.5,4.5,4.5), Circle(Point(3,4),(Point(2,3) - Point(3,4)).norm()).projection(Point(5,5))); };
TEST(Circle, Intersection_Segment_ox_2){ vector<Point> ans = { Point(sqrt(2.),sqrt(2.)), Point(-sqrt(2.),sqrt(2.)) }; ASSERT_EQ(ans, Circle(Point(4,4),2).intersection(Segment(-3,sqrt(2.),3,sqrt(2.)))); };
void MapWindow::DrawTask(HDC hdc, RECT rc, const POINT &Orig_Aircraft) { int i; double tmp; COLORREF whitecolor = RGB_WHITE; COLORREF origcolor = SetTextColor(hDCTemp, whitecolor); HPEN oldpen = 0; HBRUSH oldbrush = 0; static short size_tasklines=0; if (DoInit[MDI_DRAWTASK]) { switch (ScreenSize) { case ss480x272: case ss272x480: case ss320x240: case ss240x320: size_tasklines=NIBLSCALE(4); break; default: size_tasklines=NIBLSCALE(3); break; } DoInit[MDI_DRAWTASK]=false; } if (!WayPointList) return; oldpen = (HPEN) SelectObject(hdc, hpStartFinishThick); oldbrush = (HBRUSH) SelectObject(hdc, GetStockObject(HOLLOW_BRUSH)); LockTaskData(); // protect from external task changes for (i = 1; ValidTaskPoint(i); i++) { if (!ValidTaskPoint(i + 1)) { // final waypoint if (ActiveWayPoint > 1 || !ValidTaskPoint(2)) { // only draw finish line when past the first // waypoint. FIXED 110307: or if task is with only 2 tps DrawStartEndSector(hdc, rc, Task[i].Start, Task[i].End, Task[i].Index, FinishLine, FinishRadius); } } else { // normal sector if (AATEnabled != TRUE) { //_DrawLine(hdc, PS_DASH, NIBLSCALE(3), WayPointList[Task[i].Index].Screen, Task[i].Start, RGB_PETROL, rc); //_DrawLine(hdc, PS_DASH, NIBLSCALE(3), WayPointList[Task[i].Index].Screen, Task[i].End, RGB_PETROL, rc); DrawDashLine(hdc, size_tasklines, WayPointList[Task[i].Index].Screen, Task[i].Start, RGB_PETROL, rc); DrawDashLine(hdc, size_tasklines, WayPointList[Task[i].Index].Screen, Task[i].End, RGB_PETROL, rc); } int Type = SectorType; double Radius = SectorRadius; if (AATEnabled) { Type = Task[i].AATType; Radius = Task[i].AATCircleRadius; } switch (Type) { case CIRCLE: tmp = Radius * zoom.ResScaleOverDistanceModify(); Circle(hdc, WayPointList[Task[i].Index].Screen.x, WayPointList[Task[i].Index].Screen.y, (int) tmp, rc, false, false); break; case SECTOR: tmp = Radius * zoom.ResScaleOverDistanceModify(); Segment(hdc, WayPointList[Task[i].Index].Screen.x, WayPointList[Task[i].Index].Screen.y, (int) tmp, rc, Task[i].AATStartRadial - DisplayAngle, Task[i].AATFinishRadial - DisplayAngle); break; case 2: if (!AATEnabled) { // this Type exist only if not AAT task // JMW added german rules tmp = 500 * zoom.ResScaleOverDistanceModify(); Circle(hdc, WayPointList[Task[i].Index].Screen.x, WayPointList[Task[i].Index].Screen.y, (int) tmp, rc, false, false); tmp = 10e3 * zoom.ResScaleOverDistanceModify(); Segment(hdc, WayPointList[Task[i].Index].Screen.x, WayPointList[Task[i].Index].Screen.y, (int) tmp, rc, Task[i].AATStartRadial - DisplayAngle, Task[i].AATFinishRadial - DisplayAngle); } break; } if (AATEnabled && !DoOptimizeRoute()) { // ELSE HERE IS *** AAT *** // JMW added iso lines if ((i == ActiveWayPoint) || (mode.Is(Mode::MODE_TARGET_PAN) && (i == TargetPanIndex))) { // JMW 20080616 flash arc line if very close to target static bool flip = false; if (DerivedDrawInfo.WaypointDistance < AATCloseDistance()*2.0) { flip = !flip; } else { flip = true; } if (flip) { for (int j = 0; j < MAXISOLINES - 1; j++) { if (TaskStats[i].IsoLine_valid[j] && TaskStats[i].IsoLine_valid[j + 1]) { _DrawLine(hdc, PS_SOLID, NIBLSCALE(2), TaskStats[i].IsoLine_Screen[j], TaskStats[i].IsoLine_Screen[j + 1], RGB(0, 0, 255), rc); } } } } } } } if ((ActiveWayPoint < 2) && ValidTaskPoint(0) && ValidTaskPoint(1)) { DrawStartEndSector(hdc, rc, Task[0].Start, Task[0].End, Task[0].Index, StartLine, StartRadius); if (EnableMultipleStartPoints) { for (i = 0; i < MAXSTARTPOINTS; i++) { if (StartPoints[i].Active && ValidWayPoint(StartPoints[i].Index)) { DrawStartEndSector(hdc, rc, StartPoints[i].Start, StartPoints[i].End, StartPoints[i].Index, StartLine, StartRadius); } } } } for (i = 0; ValidTaskPoint(i + 1); i++) { bool is_first = (Task[i].Index < Task[i + 1].Index); int imin = min(Task[i].Index, Task[i + 1].Index); int imax = max(Task[i].Index, Task[i + 1].Index); // JMW AAT! double bearing = Task[i].OutBound; POINT sct1, sct2; if (AATEnabled) { LatLon2Screen(Task[i].AATTargetLon, Task[i].AATTargetLat, sct1); LatLon2Screen(Task[i + 1].AATTargetLon, Task[i + 1].AATTargetLat, sct2); DistanceBearing(Task[i].AATTargetLat, Task[i].AATTargetLon, Task[i + 1].AATTargetLat, Task[i + 1].AATTargetLon, NULL, &bearing); // draw nominal track line DrawDashLine(hdc, NIBLSCALE(1), // 091217 WayPointList[imin].Screen, WayPointList[imax].Screen, taskcolor, rc); } else { sct1 = WayPointList[Task[i].Index].Screen; sct2 = WayPointList[Task[i + 1].Index].Screen; } if ((i >= ActiveWayPoint && DoOptimizeRoute()) || !DoOptimizeRoute()) { if (is_first) { DrawMulticolorDashLine(hdc, size_tasklines, sct1, sct2, taskcolor, RGB_BLACK,rc); } else { DrawMulticolorDashLine(hdc, size_tasklines, sct2, sct1, taskcolor, RGB_BLACK,rc); } // draw small arrow along task direction POINT p_p; POINT Arrow[2] = { {6, 6}, {-6, 6} }; ScreenClosestPoint(sct1, sct2, Orig_Aircraft, &p_p, NIBLSCALE(25)); PolygonRotateShift(Arrow, 2, p_p.x, p_p.y, bearing - DisplayAngle); _DrawLine(hdc, PS_SOLID, size_tasklines-NIBLSCALE(1), Arrow[0], p_p, taskcolor, rc); _DrawLine(hdc, PS_SOLID, size_tasklines-NIBLSCALE(1), Arrow[1], p_p, taskcolor, rc); } } { UnlockTaskData(); } // restore original color SetTextColor(hDCTemp, origcolor); SelectObject(hdc, oldpen); SelectObject(hdc, oldbrush); }
TEST(Circle, Intersection_Segment_tangent){ vector<Point> ans; ASSERT_EQ(ans, Circle(Point(4,4),2).intersection(Segment(2*sqrt(2.),0,0,2*sqrt(2.)))); };
int main(void) { uint8_t i, x, y; MCU_initialize(); // initialize MCU and kit Delay_ms(50); // wait for system stabilization LCD_initialize(); // initialize text LCD module Beep(); Clear_screen(); // initialize GLCD screen LCD_string(0x80, "Graphic LCD Test"); // display title on text LCD while (1) { LCD_string(0xC0, " (1) Lines "); // graphic show 1 Rectangle(0, 0, 63, 127); Delay_ms(300); for (i = 0, x = 7, y = 15; i <= 7; i++, x += 8, y += 16) { Line(x, 0, 0, y); Line(0, 127 - y, x, 127); Delay_ms(300); } for (i = 0, x = 7, y = 15; i <= 7; i++, x += 8, y += 16) { Line(63, y, x, 127); Line(x, 0, 63, 127 - y); Delay_ms(300); } Delay_ms(3000); Clear_screen(); LCD_string(0xC0, " (2) Rectangles "); // graphic show 2 for (i = 0, x = 0, y = 0; i <= 7; i++, x += 4, y += 8) { Rectangle(x, y, 63 - x, 127 - y); Delay_ms(300); } Delay_ms(1000); for (i = 0; i <= 63; i++) { // (scroll up) GLCD_command(0xC0, 0xC0 + i); Delay_ms(100); } GLCD_command(0xC0, 0xC0); Delay_ms(3000); Clear_screen(); for (i = 0, x = 0, y = 0; i <= 7; i++, x += 4, y += 4) { // (two) Rectangle(x, y, 63 - x, 63 - y); Rectangle(x, y + 64, 63 - x, 127 - y); Delay_ms(300); } Delay_ms(3000); Clear_screen(); LCD_string(0xC0, " (3) Circles "); // graphic show 3 Rectangle(0, 0, 63, 127); Delay_ms(300); for (i = 7; i <= 63; i += 8) { Circle(31, 63, i); Delay_ms(300); } Delay_ms(1000); for (i = 63; i != 0; i--) { // (scroll down) GLCD_command(0xC0, 0xC0 + i); Delay_ms(100); } GLCD_command(0xC0, 0xC0); Delay_ms(3000); Clear_screen(); for (i = 3; i <= 31; i += 4) { // (two) Circle(31, 31, i); Circle(31, 95, i); Delay_ms(300); } Delay_ms(3000); Clear_screen(); LCD_string(0xC0, " (4) Sine Curve "); // graphic show 4 Line(32, 0, 32, 127); // (X axis) Line(29, 124, 32, 127); Line(35, 124, 32, 127); Line(31, 33, 33, 33); Line(31, 63, 33, 63); Line(31, 93, 33, 93); Line(31, 123, 33, 123); Line(0, 3, 63, 3); // (Y axis) Line(3, 0, 0, 3); Line(3, 6, 0, 3); for (i = 5; i <= 30; i += 5) { Sine(i); Delay_ms(300); } Delay_ms(3000); Clear_screen(); LCD_string(0xC0, "(5) Cosine Curve"); // graphic show 5 Line(32, 0, 32, 127); // (X axis) Line(29, 124, 32, 127); Line(35, 124, 32, 127); Line(31, 33, 33, 33); Line(31, 63, 33, 63); Line(31, 93, 33, 93); Line(31, 123, 33, 123); Line(0, 3, 63, 3); // (Y axis) Line(3, 0, 0, 3); Line(3, 6, 0, 3); for (i = 5; i <= 30; i += 5) { Cosine(i); Delay_ms(300); } Delay_ms(3000); Clear_screen(); } return 0; }
int main(int argc, char* argv[]) { Window win{std::make_pair(800,800)}; //Kreise std::vector<Circle>MeinWunderschoenenKreise; MeinWunderschoenenKreise.push_back(Circle(Vec2(0.5f, 0.5f), 0.3f, Color(0.0f, 0.0f, 0.0f))); MeinWunderschoenenKreise.push_back(Circle(Vec2(0.5f, 0.5f), 0.28f, Color(0.0f, 0.0f, 0.0f))); //Knechtecke std::vector<Rectangle>Knechtecke; Knechtecke.push_back(Rectangle(0.6f, 0.6f, Color(0.0f, 0.0f, 0.0f), Vec2(0.2f, 0.2f))); while (!win.should_close()) { if (win.is_key_pressed(GLFW_KEY_ESCAPE)) { win.close(); } auto t = win.get_time(); Vec2 mouse_pos = Vec2(win.mouse_position().first, win.mouse_position().second); if(MeinWunderschoenenKreise[0].is_inside(mouse_pos)){ MeinWunderschoenenKreise[0].draw(win, Color{0, 1, 0.9}); float x1{0.5f + 0.35f * std::sin(5.f*t)}; float y1{0.5f + 0.35f * std::cos(5.f*t)}; win.draw_point(x1, y1, 0.0f, 1.0f, 0.9f); } else{MeinWunderschoenenKreise[0].draw(win, Color{1,0,0}); float x1{0.5f + 0.35f * std::sin(t)}; float y1{0.5f + 0.35f * std::cos(t)}; win.draw_point(x1, y1, 1.0f, 0.0f, 0.0f); } if(MeinWunderschoenenKreise[1].is_inside(mouse_pos)){ MeinWunderschoenenKreise[1].moire(win, Color{0, 1, 0.9}); float x2{0.25f + 0.04f * std::sin(15.0f*t)}; float y2{0.25f + 0.04f * std::cos(15.0f*t)}; float x3{0.25f + 0.04f * std::sin(15.0f*t)}; float y3{0.75f + 0.04f * std::cos(15.0f*t)}; float x4{0.75f + 0.04f * std::sin(15.0f*t)}; float y4{0.75f + 0.04f * std::cos(15.0f*t)}; float x5{0.75f + 0.04f * std::sin(15.0f*t)}; float y5{0.25f + 0.04f * std::cos(15.0f*t)}; win.draw_point(x2, y2, 0.0f, 1.0f, 0.9f); win.draw_point(x3, y3, 0.0f, 1.0f, 0.9f); win.draw_point(x4, y4, 0.0f, 1.0f, 0.9f); win.draw_point(x5, y5, 0.0f, 1.0f, 0.9f); } else{MeinWunderschoenenKreise[1].moire(win, Color{});} if (Knechtecke[0].is_inside(mouse_pos)){ Knechtecke[0].draw(win, Color{0, 1, 0.9}); } else{Knechtecke[0].draw(win, Color{1,0,0});} /*auto t = win.get_time(); float x1{0.5f + 0.35f * std::sin(t)}; float y1{0.5f + 0.35f * std::cos(t)}; win.draw_point(x1, y1, 1.0f, 0.0f, 0.0f); float x2{0.5f + 0.5f * std::sin(5.0f*t)}; float y2{0.5f + 0.5f * std::cos(5.0f*t)}; win.draw_point(x2, y2, 0.0f, 1.0f, 0.0f); float x3{0.5f + 0.5f * std::sin(5.0f*t)}; float y3{0.5f + 0.5f * std::cos(5.0f*t)}; win.draw_point(x3, y3, 0.0f, 0.0f, 1.0f); auto m = win.mouse_position(); win.draw_line(0.1f, 0.1f, 0.8f,0.1f, 1.0,0.0,0.0); win.draw_line(0.0f, m.second, 0.01f, m.second, 0.0, 0.0, 0.0); win.draw_line(0.99f, m.second,1.0f, m.second, 0.0, 0.0, 0.0); win.draw_line(m.first, 0.0f, m.first, 0.01f, 0.0, 0.0, 0.0); win.draw_line(m.first, 0.99f,m.first, 1.0f, 0.0, 0.0, 0.0);*/ win.update(); } return 0; }
void MapWindow::DrawRunway(HDC hdc,WAYPOINT* wp, RECT rc, double fScaleFact, BOOL picto) { int solid= false; HPEN oldPen ; HBRUSH oldBrush ; bool bGlider = false; bool bOutland = false; bool bRunway = false; double rwl = 5.33; double rwb = 1.0; double cir = 4.0; static double scale_drawradio=0; static double scale_bigfont=0; static double scale_fullinfos=0; int Center_x = wp->Screen.x; int Center_y = wp->Screen.y; if(picto) { Center_x = rc.left+ (rc.right- rc.left)/2; Center_y = rc.bottom +(rc.top-rc.bottom)/2; } int l,p,b; switch(ScreenSize) { case ss240x320: case ss320x240: case ss480x272: case ss272x480: fScaleFact /= 800; // (*=1.6 after /= 1600 is equale to /1000) break; default: fScaleFact /=1600; break; } if (DoInit[MDI_MAPWPVECTORS]) { // All values <= switch(ScreenSize) { case ss480x272: if (ScreenSizeX==854) { scale_drawradio=3.6; scale_bigfont=1.5; scale_fullinfos=1.5; } else { scale_drawradio=2.6; scale_bigfont=1.1; scale_fullinfos=0.8; } break; case ss800x480: scale_drawradio=2.6; scale_bigfont=1.5; scale_fullinfos=1.5; break; case ss640x480: scale_drawradio=3.6; scale_bigfont=1.5; scale_fullinfos=1.5; break; default: scale_drawradio=2.6; scale_bigfont=1.5; scale_fullinfos=1.5; break; } DoInit[MDI_MAPWPVECTORS]=false; } if( wp->RunwayLen > 100) /* square if no runway defined */ { l = (int) (rwl * (1.0+ ((double)wp->RunwayLen/800.0-1.0)/4.0)); } else { l = (int)( rwl*0.5); rwb = l ; } l = (int)(l * fScaleFact*1.1); if(l==0) l=1; b = (int)(rwb * fScaleFact); if(b==0) b=1; p = (int)(cir * (double)ScreenScale * fScaleFact); if(p==0) p=1; switch(wp->Style) { case STYLE_AIRFIELDSOLID: solid = true; bRunway = true; bOutland = false; bGlider = false; break; case STYLE_AIRFIELDGRASS: solid = false; bRunway = true; bOutland = false; bGlider = false; break; case STYLE_OUTLANDING : solid = false; bRunway = true; bOutland = true; bGlider = false; b*=2; break; case STYLE_GLIDERSITE : solid = false; bRunway = true; bOutland = false; bGlider = true; break; default: return; break; } oldPen = (HPEN) SelectObject(hdc, GetStockObject(BLACK_PEN)); oldBrush = (HBRUSH)SelectObject(hdc, LKBrush_Red); if( wp->Reachable == TRUE) SelectObject(hdc, LKBrush_Green); if(!bOutland) { Circle( hdc,Center_x, Center_y, p, rc,false, true); } if(bRunway) { POINT Runway[5] = { { b, l }, // 1 {-b, l }, // 2 {-b,-l }, // 3 { b,-l }, // 4 { b,l } // 5 }; if(!bOutland) { if(solid) SelectObject(hdc, LKBrush_DarkGrey ); else SelectObject(hdc, LKBrush_White); } PolygonRotateShift(Runway, 5, Center_x, Center_y, wp->RunwayDir- (int)MapWindow::GetDisplayAngle()); Polygon(hdc,Runway ,5 ); } // bRunway if(fScaleFact >= 1.2) { if(bGlider) { double fFact = 0.04*fScaleFact/1.5; POINT WhiteWing [17] = { { (long)(-228 * fFact ) , (long)(13 * fFact)}, //1 { (long) (-221 * fFact ) , (long)(-5 * fFact)}, //2 { (long) (-102 * fFact ) , (long)(-50 * fFact)}, //3 { (long) (8 * fFact ) , (long)( 5 * fFact)}, //4 { (long) (149 * fFact ) , (long)(-55 * fFact)}, //5 { (long) (270 * fFact ) , (long)(-12 * fFact)}, //6 { (long) (280 * fFact ) , (long)( 5 * fFact)}, //7 { (long) (152 * fFact ) , (long)(-30 * fFact)}, //8 { (long) (48 * fFact ) , (long)( 27 * fFact)}, //9 { (long) (37 * fFact ) , (long)( 44 * fFact)}, //10 { (long)(-20 * fFact ) , (long)( 65 * fFact)}, //11 { (long)(-29 * fFact ) , (long)( 80 * fFact)}, //12 { (long)(-56 * fFact ) , (long)( 83 * fFact)}, //13 { (long)(-50 * fFact ) , (long)( 40 * fFact)}, //14 { (long)(-30 * fFact ) , (long)( 27 * fFact)}, //15 { (long)(-103 * fFact ) , (long)(-26 * fFact)}, //16 { (long)(-228 * fFact ) , (long)( 13 * fFact)} //17 }; PolygonRotateShift(WhiteWing, 17, Center_x, Center_y, 0/*+ wp->RunwayDir-Brg*/); Polygon(hdc,WhiteWing ,17 ); } } // StartupStore(_T(".......fscale=%f *1600=%f realscale = %f\n"), fScaleFact, fScaleFact*1600, MapWindow::zoom.RealScale()); if( MapWindow::zoom.RealScale() <= scale_drawradio ) { HFONT hfOld; if (MapWindow::zoom.RealScale() <= scale_bigfont) hfOld = (HFONT)SelectObject(hdc, LK8PanelUnitFont); else hfOld = (HFONT)SelectObject(hdc, LK8UnitFont); if (INVERTCOLORS) SelectObject(hdc,LKBrush_Petrol); else SelectObject(hdc,LKBrush_LightCyan); unsigned int offset = p + NIBLSCALE(1) ; if( !picto) { if ( _tcslen(wp->Freq)>0 ) { MapWindow::LKWriteBoxedText(hdc,&DrawRect,wp->Freq, Center_x- offset, Center_y -offset, 0, WTALIGN_RIGHT, RGB_WHITE, RGB_BLACK); } // // Full infos! 1.5km scale // if (MapWindow::zoom.RealScale() <=scale_fullinfos) { if ( _tcslen(wp->Code)==4 ) { MapWindow::LKWriteBoxedText(hdc,&DrawRect,wp->Code,Center_x + offset, Center_y - offset, 0, WTALIGN_LEFT, RGB_WHITE,RGB_BLACK); } if (wp->Altitude >0) { TCHAR tAlt[20]; _stprintf(tAlt,_T("%.0f %s"),wp->Altitude*ALTITUDEMODIFY,Units::GetUnitName(Units::GetUserAltitudeUnit())); MapWindow::LKWriteBoxedText(hdc,&DrawRect,tAlt, Center_x + offset, Center_y + offset, 0, WTALIGN_LEFT, RGB_WHITE, RGB_BLACK); } } } SelectObject(hdc, hfOld); } SelectObject(hdc, oldPen); SelectObject(hdc, oldBrush); }
void Arc::CircleCollider::render( const RenderTarget* renderTarget, Point pos, Vector2 origin /*= Vector2::ZERO*/ ) { renderTarget->drawCircle(Circle(CircleMask.pos() + pos, CircleMask.Radius), Color::GREEN, 0.0f, origin); }
void Object::doCollision(Background &bg) { WallSet set; const TileMap &tilemap = bg.getTileMap(); /* get tile bounds of circle */ int l = (int)floor((pos.x-radius)/8), r = (int)ceil((pos.x+radius)/8); int t = (int)floor((pos.y-radius)/8), b = (int)ceil((pos.y+radius)/8); /* add all walls declared for the tiles */ for (int j= t; j < b; j++) for (int i= l; i < r; i++) { const TileMapEntry *tme = tilemap.index(i,j); set.addFromTile(tme); } /* we want to ignore certain walls (tops of ladders when climbing through them, and one way walls). This loop removes walls from the ignore list if the object doesn't intersect with it */ { Wall::CPListIterator i; for (i = ignore.begin(); i != ignore.end();) { const Segment &s = (**i).wall.segment; if (!s.intersect(Circle(pos, radius))) ignore.erase(i++); else ++i; } } /* all the collision gets messed up when the sometimes here/sometimes not walls enter the equation */ bool irregularWalls = false; { WallSet::Iterator i; for (i = set.begin(); i != set.end(); ++i) { const Edge::EdgeType &type = (**i).wall.type; if (type == Edge::LADDER_TOP || type == Edge::ONE_WAY) { irregularWalls = true; break; } } } /* check all walls found above for collision */ WallSet::Iterator i; Segment::List collide; for (i = set.begin(); i != set.end(); ++i) { const Wall &w = (**i); const Segment &s = w.wall.segment; preProcessWall(**i); /* don't process it if it's in the ignore list... */ if (std::find(ignore.begin(), ignore.end(), &w) != ignore.end()) continue; /* we wait to do segment-circle collision if we're doing complicated collision */ if (!irregularWalls) { /* ...or if it doesn't even intersect the circle */ if (!s.intersect(Circle(pos, radius))) continue; } if (processWall(**i)) { if (irregularWalls) collide.push_back((**i).wall.segment); else collideWall((**i).wall.segment); } } /* the problem with using normal collision: if we have some walls that are here today/gone tomorrow the collision will be irregular because of the way segment-circle collision works. when the circle collides with two walls with the same normal near their intersection point, one of the segments will (probably) provide a shunt vector that is not the normal, whereas the other (probably) will. This will push the object in the direction of the vector, even though it shouldn't. how to fix it (basic idea): * combine collinear segment that intersect at a point like in Walls::addWall * sometimes walls will exist on the other side of this newly created wall. If the object is on the normal side, remove this "T-Bone" wall. */ if (irregularWalls) { /* combine collinear segments that intersect at a point, like in Walls::addWall */ Segment::ListIterator k, l; for (k = collide.begin(); k != collide.end();) { bool removed = false; const Segment &s = *k; l = k; for (++l; l != collide.end(); ++l) { const Segment &t = *l; Point p0, p1; Segment::IntersectType it = s.intersect(t,p0,p1); if (it != Segment::COLLINEAR_POINT) continue; if (s.normal != t.normal) continue; if (p0 == t.p0) collide.push_back(Segment(s.p0, t.p1)); else collide.push_back(Segment(t.p0, s.p1)); collide.erase(k++); if (k == l) collide.erase(k++); else collide.erase(l); removed = true; break; } if (!removed) ++k; } /* look for edges that T-bone another segment */ for (k = collide.begin(); k != collide.end();) { bool removed = false; const Segment &s = *k; l = k; for (++l; l != collide.end(); ++l) { const Segment &t = *l; Point p0, p1; Segment::IntersectType it = s.intersect(t,p0,p1); if (it != Segment::POINT) continue; /* we know that the combined segments are at the end of the collide list, therefore if two segments are T-boned, the top of the "T" must be t and the base of the "T" must be s. Therefore, if the intersection point is t, we know it can't be a T-bone. */ if (p0 == t.p0 || p0 == t.p1) continue; /* find which point connects the top of the "T" to the base. */ if (p0 == s.p0) { /* we'll erase the base if the top normal points away from the base and if the object is on the top normal side */ if (!t.faces(s.p1) && t.faces(pos)) { collide.erase(k++); removed = true; break; } } else if (p0 == s.p1) { /* we'll erase the base if the top normal points away from the base and if the object is on the top normal side */ if (!t.faces(s.p0) && t.faces(pos)) { collide.erase(k++); removed = true; break; } } } if (!removed) ++k; } /* shunt object around to avoid collision */ for (k = collide.begin(); k != collide.end(); ++k) { const Segment &s = *k; /* this check is necessary, if we check walls without moving the object, we get false positives */ if (s.intersect(Circle(pos, radius))) collideWall(*k); } } }
void Main() { Chiritori me; std::list<Circle> trash; Color trashCol = { 200, 200, 200, 255 }; int32 score = 0; Font font(20); while (System::Update()) { Vec2 angle(cos(me.angle), sin(me.angle)); // ゴミ出現 if (RandomBool(1.0 / 50)) { Point p = RandomPoint({ 15, 15, Window::Width() - 15, Window::Height() - 15 }); trash.push_back(Circle(p, 15)); } // 操作 if (Input::KeySpace.pressed) { me.pos.x += me.v * angle.x; me.pos.y += me.v * angle.y; if (me.pos.y - me.r < 0 || me.pos.y + me.r >= Window::Height()) { me.angle = -me.angle; } if (me.pos.x - me.r < 0 || me.pos.x + me.r >= Window::Width()) { me.angle = Pi - me.angle; } } else { me.angle += me.angleV; } // ゴミ回収 for (auto it = trash.begin(); it != trash.end(); ) { if (Circle(me.pos, me.r).intersects(*it)) { it = trash.erase(it); ++score; } else { ++it; } } // ゴミ増えすぎどっかーん if (trash.size() >= 30) { trash.clear(); score = 0; me = Chiritori(); } // 描画 uint32 bk = 0; if (trash.size() > 20) { bk = (trash.size() - 20) * 25; } Graphics::SetBackground({ bk, bk, 0, 255 }); Circle(me.pos, me.r).draw(me.color); Circle({ me.pos.x + me.r * 0.6 * angle.x, me.pos.y + me.r * 0.6 * angle.y }, me.r * 0.2).draw({ 255, 255, 255, 255 }); for each (Circle c in trash) { c.draw(trashCol); } font(ToString(score)).draw(); }
/** * 外接圆 */ Circle Triangle::GetGetCircumCircle() const{ return Circle(m_vPtA, m_vPtB, m_vPtC); }
SOFTWARE. *******************************************************************************/ #include "MathUtils.h" NAMESPACE_MAGICAL struct Vector2; struct Circle; #include "Vector2.h" #include "Vector2.inl" #include "Circle.h" #include "Circle.inl" const Circle Circle::One = Circle( 0.0f, 0.0f, 1.0f ); const Circle Circle::Invalid = Circle( 0.0f, 0.0f, -1.0f ); void Circle::scale( Circle& out, const Circle& circle, float s ) { out.x = circle.x; out.y = circle.y; out.r = circle.r * s; } void Circle::merge( Circle& out, const Circle& circle1, const Circle& circle2 ) { Vector2 mid = Vector2::midPointBetween( circle1.center, circle2.center ); float distance = Vector2::distance( circle1.center, circle2.center ); out.center = mid;
Python CChamfer::AppendTextForCircularChildren( CMachineState *pMachineState, const double theta, HeeksObj *child, CTool *pChamferingBit ) { Python python; // See what the maximum possible depth is for this chamfering bit. We want to figure // out whether we can cut with the middle part of the chamfering bit rather than // cutting using the very tip (we don't want to break it off). In fact, we should // really cut with the top-most cutting edge so that it's as strong as it can be. This // depends on the area available for fitting the chamfering bit. double min_chamfer_diameter = pChamferingBit->m_params.m_flat_radius * 2.0; double stand_off = m_depth_op_params.m_rapid_safety_space; double clearance_height = m_depth_op_params.ClearanceHeight(); Circles_t circles; if (child->GetType() == DrillingType) { // Get the size of the drilled holes. We need to know whether we need to just plunge // the chamfering bit directly down into the hole or whether we need to run // around the edge. CDrilling *pDrilling = (CDrilling *) child; CTool *pDrillBit = CTool::Find( pDrilling->m_tool_number ); if (pDrillBit == NULL) { // It's difficult to drill a hole without a drill bit but apparently this file does. printf("Ignoring drilling operation (id=%d) with no tool defined\n", pDrilling->m_id ); return(python); // Empty. } stand_off = pDrilling->m_params.m_standoff; clearance_height = pDrilling->m_params.ClearanceHeight(); double hole_diameter = pDrillBit->CuttingRadius(false) * 2.0; if (hole_diameter < min_chamfer_diameter) { // The flat radius at the bottom of the chamfering bit is larger than the drilled hole. It won't fit in. printf("Ignoring chamfer for drilled hole due to geometry of selected chamfering bit\n"); return(python); // Empty. } // Get all the point locations relevant for this operation and then adjust their position to align with // the current fixture. std::vector<CNCPoint> locations = CDrilling::FindAllLocations(pDrilling, pMachineState->Location(), true, NULL); for (std::vector<CNCPoint>::const_iterator l_itLocation = locations.begin(); l_itLocation != locations.end(); l_itLocation++) { CNCPoint point = pMachineState->Fixture().Adjustment( *l_itLocation ); circles.push_back( Circle( point, hole_diameter, pDrilling->m_params.m_depth ) ); } // End for } // End if - then if (child->GetType() == CounterBoreType) { CCounterBore *pCounterBore = ((CCounterBore *) child); stand_off = pCounterBore->m_depth_op_params.m_rapid_safety_space; clearance_height = pCounterBore->m_depth_op_params.ClearanceHeight(); std::vector<CNCPoint> locations = CDrilling::FindAllLocations(pCounterBore, pMachineState->Location(), pCounterBore->m_params.m_sort_locations != 0, NULL); for (std::vector<CNCPoint>::const_iterator l_itLocation = locations.begin(); l_itLocation != locations.end(); l_itLocation++) { CNCPoint point = pMachineState->Fixture().Adjustment( *l_itLocation ); double max_depth = pCounterBore->m_depth_op_params.m_start_depth - pCounterBore->m_depth_op_params.m_final_depth; circles.push_back( Circle( point, pCounterBore->m_params.m_diameter, max_depth ) ); } // End for } // Now handle all the chamfering for both the drilled holes and/or the counterbores. // The circles indicate both the diameter and the depth of either hole. for (Circles_t::iterator l_itCircle = circles.begin(); l_itCircle != circles.end(); l_itCircle++) { // We want to select a depth such that we're cutting with the top-most part of the chamfering // bit as that is the strongest part. We don't want to break off the tip unless we really can't // get into the hole without doing so. double max_hole_depth = l_itCircle->MaxDepth(); double max_bit_plunge_depth = pChamferingBit->m_params.m_cutting_edge_height * cos(theta); double min_bit_radius = pChamferingBit->m_params.m_flat_radius; double hole_radius = l_itCircle->Diameter() / 2.0; double required_bit_plunge_depth = (m_params.m_chamfer_width * cos( theta )); if ((required_bit_plunge_depth >= max_hole_depth) || (required_bit_plunge_depth >= max_bit_plunge_depth) || (hole_radius < min_bit_radius)) { // It's too deep for one pass. return(python); // Empty. } double plunge_depth = (max_hole_depth<=max_bit_plunge_depth)?max_hole_depth:max_bit_plunge_depth; double bit_radius_at_plunge_depth = pChamferingBit->m_params.m_flat_radius + (plunge_depth / tan(theta)); // This is the gap between the bit and the hole when the bit's bottom is at the top surface. double gap_radius = hole_radius - min_bit_radius; // We need to figure out how far down to move before this gap is closed by the slope of the cutting edge. double gap_closure_depth = gap_radius / tan(theta); if ( hole_radius <= bit_radius_at_plunge_depth ) { // We can plunge straight down at the hole's location. // If the chamfering bit is at the top of the hole then the diameter of // cut is equal to the flat radius. How far should we plunge down before // the edge of the chamfering bit touches the top of the hole? CNCPoint point(l_itCircle->Location()); python << _T("drill(") << _T("x=") << point.X(true) << _T(", ") << _T("y=") << point.Y(true) << _T(", ") << _T("z=") << drawing_units(point.Z(false) - gap_closure_depth) << _T(", ") << _T("depth=") << drawing_units(required_bit_plunge_depth) << _T(", ") << _T("standoff=") << drawing_units(stand_off) << _T(", ") << _T("dwell=") << 0.0 << _T(", ") << _T("peck_depth=") << 0.0 << _T(", ") << _T("clearance_height=") << drawing_units(clearance_height) << _T(")\n"); } else { // We will have to run around the edge of the large hole. Figure out the offset // in from the edge and generate the corresponding tool path. CNCPoint centre(l_itCircle->Location()); CNCPoint point(l_itCircle->Location()); double radius_of_spiral = hole_radius - bit_radius_at_plunge_depth + (m_params.m_chamfer_width * sin(theta)); python << _T("rapid( x=") << centre.X(true) << _T(", ") << _T("y=") << centre.Y(true) << _T(", ") << _T("z=") << drawing_units(clearance_height) << _T(")\n"); python << _T("rapid(z=") << drawing_units(stand_off) << _T(")\n"); double cutting_depth = point.Z(false) - plunge_depth; // Move to 12 O'Clock. python << _T("feed( x=") << centre.X(true) << _T(", ") _T("y=") << drawing_units(centre.Y(false) + radius_of_spiral) << _T(", ") _T("z=") << drawing_units(cutting_depth) << _T(")\n"); point.SetX( centre.X(false) ); point.SetY( centre.Y(false) + radius_of_spiral ); // First quadrant (12 O'Clock to 9 O'Clock) python << _T("arc_ccw( x=") << drawing_units(centre.X(false) - radius_of_spiral) << _T(", ") << _T("y=") << centre.Y(true) << _T(", ") << _T("z=") << drawing_units(cutting_depth) << _T(", ") << // full depth _T("i=") << drawing_units(centre.X(false)) << _T(", ") << _T("j=") << drawing_units(centre.Y(false)) << _T(")\n"); point.SetX( centre.X(false) - radius_of_spiral ); point.SetY( centre.Y(false) ); // Second quadrant (9 O'Clock to 6 O'Clock) python << _T("arc_ccw( x=") << centre.X(true) << _T(", ") << _T("y=") << drawing_units(centre.Y(false) - radius_of_spiral) << _T(", ") << _T("z=") << drawing_units(cutting_depth) << _T(", ") << // full depth now _T("i=") << drawing_units(centre.X(false)) << _T(", ") << _T("j=") << drawing_units(centre.Y(false)) << _T(")\n"); point.SetX( centre.X(false) ); point.SetY( centre.Y(false) - radius_of_spiral ); // Third quadrant (6 O'Clock to 3 O'Clock) python << _T("arc_ccw( x=") << drawing_units(centre.X(false) + radius_of_spiral) << _T(", ") << _T("y=") << centre.Y(true) << _T(", ") << _T("z=") << drawing_units(cutting_depth) << _T(", ") << // full depth now _T("i=") << drawing_units(centre.X(false)) << _T(", ") << _T("j=") << drawing_units(centre.Y(false)) << _T(")\n"); point.SetX( centre.X(false) + radius_of_spiral ); point.SetY( centre.Y(false) ); // Fourth quadrant (3 O'Clock to 12 O'Clock) python << _T("arc_ccw( x=") << centre.X(true) << _T(", ") << _T("y=") << drawing_units(centre.Y(false) + radius_of_spiral) << _T(", ") << _T("z=") << drawing_units(cutting_depth) << _T(", ") << // full depth now _T("i=") << drawing_units(centre.X(false)) << _T(", ") << _T("j=") << drawing_units(centre.Y(false)) << _T(")\n"); point.SetX( centre.X(false) ); point.SetY( centre.Y(false) + radius_of_spiral ); python << _T("rapid( z=") << drawing_units(m_depth_op_params.ClearanceHeight()) << _T(")\n"); } } // End for return(python); }
const Circle Circle::operator + (Circle& circle) { return Circle(mRadius + circle.mRadius, mXCoord, mYCoord, mName); }
Circle Fireball::collisionCircle() { return Circle(position_, std::min(sprite_->width(), sprite_->height()) / 2.0f); }
void MapWindow::DrawTaskPicto(HDC hdc,int TaskIdx, RECT rc, double fScaleFact) { #ifdef PICTORIALS int center_x = (rc.right-rc.left)/2; int center_y = (rc.bottom-rc.top)/2; int SecType = SectorType; int width = center_x-2; HPEN oldpen = 0; HBRUSH oldbrush = 0; if(AATEnabled) oldbrush = (HBRUSH) SelectObject(hdc, LKBrush_LightGrey); else oldbrush = (HBRUSH) SelectObject(hdc, GetStockObject(HOLLOW_BRUSH)); oldpen = (HPEN) SelectObject(hdc, hpStartFinishThick); int finish=0; while( ValidTaskPoint(finish)) finish++; finish--; if(center_y < width) width = center_y-2; fScaleFact /= (2500.0); //width = (int)((double)width*(fScaleFact)); POINT startfinishline[2] = {{0,-width/2}, {0,+width/2}}; POINT track[3] = {{0,-width/10}, {width/4,0}, {0,width/10}}; if(TaskIdx == finish) { track[0].x = -width/4 ; track[0].y= -width/10; track[1].x = 0 ; track[1].y= 0; track[2].x = -width/4 ; track[2].y= width/10; } LockTaskData(); // protect from external task changes double StartRadial = Task[TaskIdx].AATStartRadial; double FinishRadial = Task[TaskIdx].AATFinishRadial; if(TaskIdx==0) { FinishRadial = Task[TaskIdx].AATStartRadial; StartRadial = Task[TaskIdx].AATFinishRadial; } double SecRadius; GetTaskSectorParameter( TaskIdx, &SecType,&SecRadius); switch (SecType) { case CIRCLE: Circle(hdc, center_x, center_y, width-2, rc, true, true); break; case SECTOR: Segment(hdc, center_x, center_y, width, rc, StartRadial, FinishRadial); break; case DAe: if (!AATEnabled) { // this Type exist only if not AAT task // JMW added german rules Circle(hdc, center_x, center_y, width/8, rc, false, true); Segment(hdc, center_x, center_y, width, rc, StartRadial, FinishRadial); } break; case LINE: default: PolygonRotateShift(startfinishline, 2, center_x, center_y, Task[TaskIdx].AATStartRadial); Polygon(hdc,startfinishline ,2 ); if((TaskIdx == 0) || (TaskIdx == finish)) { PolygonRotateShift(track, 3, center_x, center_y, Task[TaskIdx].AATStartRadial); Polygon(hdc,track ,3 ); } break; } UnlockTaskData(); SelectObject(hdc, oldpen); SelectObject(hdc, oldbrush); #endif }
const Circle Circle::operator+(const Circle& c) const { return Circle (radius()+c.radius()); // return temp; }
/******************************************************************************* Name: CircleObject Description: Primary constructor Input: vx int horizontal velocity vy int vertical velocity ******************************************************************************/ CircleObject::CircleObject(int vx, int vy) : PhysicalObject(vx, vy) { circ = Circle(pos); shape = CIRCLE; }
void KingBoo::draw() { Drawable::draw(); Sphere(Point3(location,terrainMap->getHeight(location) + 2), radius, white).draw(); Circle(Point3(location,terrainMap->getHeight(location) + .1), radius, black).draw(); }
Extrusion::Extrusion(const Path& path, double radius, uint32_t segments, uint32_t pieces, Material* m) : Mesh(Mesh::MESH_PHONG,m) { Circle circle = Circle(Vector(0,0,0),radius,Vector(0,0,1)); init(path, circle, segments, pieces,5); }
void MapWindow::DrawTRI(HDC hDC, const RECT rc) { POINT Start; static short top=(((rc.bottom-BottomSize-(rc.top+TOPLIMITER)-BOTTOMLIMITER)/PANELROWS)+rc.top+TOPLIMITER)- (rc.top+TOPLIMITER); Start.y = ((rc.bottom-BottomSize-top)/2)+top-NIBLSCALE(10); Start.x = (rc.right - rc.left)/2; HPEN hpBlack; HBRUSH hbBlack; HPEN hpWhite; HBRUSH hbWhite; HPEN hpBorder; HBRUSH hbBorder; HPEN hpOld; HBRUSH hbOld; // gauge size radius static int radius = NIBLSCALE(65); static int planesize = radius-NIBLSCALE(10); // planebody static int planeradius = NIBLSCALE(6); static int tailsize = planesize/4+NIBLSCALE(2); static int innerradius = radius - NIBLSCALE(8); static POINT d00[2][2],d15[2][4],d30[2][4], d45[2][4], d60[2][4]; TCHAR Buffer[LKSIZEBUFFERVALUE]; double beta=0.0; bool disabled=false; if (DoInit[MDI_DRAWTRI]) { top=(((rc.bottom-BottomSize-(rc.top+TOPLIMITER)-BOTTOMLIMITER)/PANELROWS)+rc.top+TOPLIMITER)- (rc.top+TOPLIMITER); radius = NIBLSCALE(65); planesize = radius-NIBLSCALE(10); planeradius = NIBLSCALE(6); tailsize = planesize/4+NIBLSCALE(2); innerradius = radius - NIBLSCALE(8); // [a][b] a=0 external circle a=1 inner circle b=1-4 d00[0][0].x= Start.x - radius; d00[0][0].y= Start.y; d00[1][0].x= Start.x - innerradius; d00[1][0].y= Start.y; d00[0][1].x= Start.x + radius; d00[0][1].y= Start.y; d00[1][1].x= Start.x + innerradius; d00[1][1].y= Start.y; d15[0][0].x= Start.x - (long) (radius*fastcosine(15.0)); d15[0][0].y= Start.y + (long) (radius*fastsine(15.0)); d15[1][0].x= Start.x - (long) (innerradius*fastcosine(15.0)); d15[1][0].y= Start.y + (long) (innerradius*fastsine(15.0)); d15[0][1].x= Start.x - (long) (radius*fastcosine(15.0)); d15[0][1].y= Start.y - (long) (radius*fastsine(15.0)); d15[1][1].x= Start.x - (long) (innerradius*fastcosine(15.0)); d15[1][1].y= Start.y - (long) (innerradius*fastsine(15.0)); d15[0][2].x= Start.x + (long) (radius*fastcosine(15.0)); d15[0][2].y= Start.y + (long) (radius*fastsine(15.0)); d15[1][2].x= Start.x + (long) (innerradius*fastcosine(15.0)); d15[1][2].y= Start.y + (long) (innerradius*fastsine(15.0)); d15[0][3].x= Start.x + (long) (radius*fastcosine(15.0)); d15[0][3].y= Start.y - (long) (radius*fastsine(15.0)); d15[1][3].x= Start.x + (long) (innerradius*fastcosine(15.0)); d15[1][3].y= Start.y - (long) (innerradius*fastsine(15.0)); d30[0][0].x= Start.x - (long) (radius*fastcosine(30.0)); d30[0][0].y= Start.y + (long) (radius*fastsine(30.0)); d30[1][0].x= Start.x - (long) (innerradius*fastcosine(30.0)); d30[1][0].y= Start.y + (long) (innerradius*fastsine(30.0)); d30[0][1].x= Start.x - (long) (radius*fastcosine(30.0)); d30[0][1].y= Start.y - (long) (radius*fastsine(30.0)); d30[1][1].x= Start.x - (long) (innerradius*fastcosine(30.0)); d30[1][1].y= Start.y - (long) (innerradius*fastsine(30.0)); d30[0][2].x= Start.x + (long) (radius*fastcosine(30.0)); d30[0][2].y= Start.y + (long) (radius*fastsine(30.0)); d30[1][2].x= Start.x + (long) (innerradius*fastcosine(30.0)); d30[1][2].y= Start.y + (long) (innerradius*fastsine(30.0)); d30[0][3].x= Start.x + (long) (radius*fastcosine(30.0)); d30[0][3].y= Start.y - (long) (radius*fastsine(30.0)); d30[1][3].x= Start.x + (long) (innerradius*fastcosine(30.0)); d30[1][3].y= Start.y - (long) (innerradius*fastsine(30.0)); d45[0][0].x= Start.x - (long) (radius*fastcosine(45.0)); d45[0][0].y= Start.y + (long) (radius*fastsine(45.0)); d45[1][0].x= Start.x - (long) (innerradius*fastcosine(45.0)); d45[1][0].y= Start.y + (long) (innerradius*fastsine(45.0)); d45[0][1].x= Start.x - (long) (radius*fastcosine(45.0)); d45[0][1].y= Start.y - (long) (radius*fastsine(45.0)); d45[1][1].x= Start.x - (long) (innerradius*fastcosine(45.0)); d45[1][1].y= Start.y - (long) (innerradius*fastsine(45.0)); d45[0][2].x= Start.x + (long) (radius*fastcosine(45.0)); d45[0][2].y= Start.y + (long) (radius*fastsine(45.0)); d45[1][2].x= Start.x + (long) (innerradius*fastcosine(45.0)); d45[1][2].y= Start.y + (long) (innerradius*fastsine(45.0)); d45[0][3].x= Start.x + (long) (radius*fastcosine(45.0)); d45[0][3].y= Start.y - (long) (radius*fastsine(45.0)); d45[1][3].x= Start.x + (long) (innerradius*fastcosine(45.0)); d45[1][3].y= Start.y - (long) (innerradius*fastsine(45.0)); d60[0][0].x= Start.x - (long) (radius*fastcosine(60.0)); d60[0][0].y= Start.y + (long) (radius*fastsine(60.0)); d60[1][0].x= Start.x - (long) (innerradius*fastcosine(60.0)); d60[1][0].y= Start.y + (long) (innerradius*fastsine(60.0)); d60[0][1].x= Start.x - (long) (radius*fastcosine(60.0)); d60[0][1].y= Start.y - (long) (radius*fastsine(60.0)); d60[1][1].x= Start.x - (long) (innerradius*fastcosine(60.0)); d60[1][1].y= Start.y - (long) (innerradius*fastsine(60.0)); d60[0][2].x= Start.x + (long) (radius*fastcosine(60.0)); d60[0][2].y= Start.y + (long) (radius*fastsine(60.0)); d60[1][2].x= Start.x + (long) (innerradius*fastcosine(60.0)); d60[1][2].y= Start.y + (long) (innerradius*fastsine(60.0)); d60[0][3].x= Start.x + (long) (radius*fastcosine(60.0)); d60[0][3].y= Start.y - (long) (radius*fastsine(60.0)); d60[1][3].x= Start.x + (long) (innerradius*fastcosine(60.0)); d60[1][3].y= Start.y - (long) (innerradius*fastsine(60.0)); DoInit[MDI_DRAWTRI]=false; } // end dirty hack doinit //if (!CALCULATED_INFO.Flying) { // speed is in m/s if(DrawInfo.Speed <5.5 && !DrawInfo.GyroscopeAvailable) disabled=true; if (disabled) { hpBlack = LKPen_Grey_N1; hbBlack = LKBrush_Grey; } else { hpBlack = LKPen_Black_N1; hbBlack = LKBrush_Black; beta = DrawInfo.GyroscopeAvailable ? DrawInfo.Roll : DerivedDrawInfo.BankAngle; } hpWhite = LKPen_White_N1; hbWhite = LKBrush_White; hpBorder = LKPen_Grey_N2; hbBorder = LKBrush_Grey; hpOld = (HPEN)SelectObject(hDC, hpWhite); hbOld = (HBRUSH)SelectObject(hDC, hbWhite); Circle(hDC, Start.x, Start.y, radius, rc, false, true ); if(DrawInfo.AccelerationAvailable) DrawAcceleration(hDC, rc); SelectObject(hDC, hpBorder); SelectObject(hDC, hbBorder); Circle(hDC, Start.x, Start.y, radius+NIBLSCALE(2), rc, false, false ); SelectObject(hDC, hpBlack); SelectObject(hDC, hbBlack); Circle(hDC, Start.x, Start.y, planeradius, rc, false, true ); _DrawLine(hDC, PS_SOLID, NIBLSCALE(1), d00[0][0], d00[1][0], RGB_BLUE,rc); _DrawLine(hDC, PS_SOLID, NIBLSCALE(1), d00[0][1], d00[1][1], RGB_BLUE,rc); _DrawLine(hDC, PS_SOLID, NIBLSCALE(1), d15[0][0], d15[1][0], RGB_BLUE,rc); _DrawLine(hDC, PS_SOLID, NIBLSCALE(1), d15[0][1], d15[1][1], RGB_BLUE,rc); _DrawLine(hDC, PS_SOLID, NIBLSCALE(1), d15[0][2], d15[1][2], RGB_BLUE,rc); _DrawLine(hDC, PS_SOLID, NIBLSCALE(1), d15[0][3], d15[1][3], RGB_BLUE,rc); _DrawLine(hDC, PS_SOLID, NIBLSCALE(1), d30[0][0], d30[1][0], RGB_BLUE,rc); _DrawLine(hDC, PS_SOLID, NIBLSCALE(1), d30[0][1], d30[1][1], RGB_BLUE,rc); _DrawLine(hDC, PS_SOLID, NIBLSCALE(1), d30[0][2], d30[1][2], RGB_BLUE,rc); _DrawLine(hDC, PS_SOLID, NIBLSCALE(1), d30[0][3], d30[1][3], RGB_BLUE,rc); _DrawLine(hDC, PS_SOLID, NIBLSCALE(1), d45[0][0], d45[1][0], RGB_BLUE,rc); _DrawLine(hDC, PS_SOLID, NIBLSCALE(1), d45[0][1], d45[1][1], RGB_BLUE,rc); _DrawLine(hDC, PS_SOLID, NIBLSCALE(1), d45[0][2], d45[1][2], RGB_BLUE,rc); _DrawLine(hDC, PS_SOLID, NIBLSCALE(1), d45[0][3], d45[1][3], RGB_BLUE,rc); _DrawLine(hDC, PS_SOLID, NIBLSCALE(1), d60[0][0], d60[1][0], RGB_BLUE,rc); _DrawLine(hDC, PS_SOLID, NIBLSCALE(1), d60[0][1], d60[1][1], RGB_BLUE,rc); _DrawLine(hDC, PS_SOLID, NIBLSCALE(1), d60[0][2], d60[1][2], RGB_BLUE,rc); _DrawLine(hDC, PS_SOLID, NIBLSCALE(1), d60[0][3], d60[1][3], RGB_BLUE,rc); POINT a1, a2; const double beta_sine = fastsine(beta); const double beta_cosine = fastcosine(beta); a1.x = Start.x - (long)(planesize * beta_cosine); a1.y = Start.y - (long)(planesize * beta_sine); a2.x = Start.x + (long)(planesize * beta_cosine); a2.y = Start.y + (long)(planesize * beta_sine); if (disabled) _DrawLine(hDC, PS_SOLID, NIBLSCALE(4), a1, a2, RGB_GREY,rc); else _DrawLine(hDC, PS_SOLID, NIBLSCALE(4), a1, a2, RGB_BLACK,rc); a1.x = Start.x; a1.y = Start.y; a2.x = Start.x + (long)(tailsize * beta_sine); a2.y = Start.y - (long)(tailsize * beta_cosine); if (disabled) _DrawLine(hDC, PS_SOLID, NIBLSCALE(4), a1, a2, RGB_GREY,rc); else _DrawLine(hDC, PS_SOLID, NIBLSCALE(4), a1, a2, RGB_BLACK,rc); SelectObject(hDC, LK8TitleFont); int bankindy=Start.y-radius/2; #ifndef __MINGW32__ if (beta > 1) _stprintf(Buffer, TEXT("%2.0f\xB0"), beta); else if (beta < -1) _stprintf(Buffer, TEXT("%2.0f\xB0"), -beta); else _tcscpy(Buffer, TEXT("--")); #else if (beta > 1) _stprintf(Buffer, TEXT("%2.0f°"), beta); else if (beta < -1) _stprintf(Buffer, TEXT("%2.0f°"), -beta); else _tcscpy(Buffer, TEXT("--")); #endif LKWriteText(hDC, Buffer, Start.x , bankindy, 0, WTMODE_NORMAL, WTALIGN_CENTER, RGB_BLUE, false); // MapDirty = true; // if (!disabled) MapWindow::RefreshMap(); SelectObject(hDC, hbOld); SelectObject(hDC, hpOld); }
TEST(Circle, Intersection_Segment_no){ vector<Point> ans; ASSERT_EQ(ans, Circle(Point(4,4),2).intersection(Segment(1,-3,2,-2))); };
bool LKSurface::CircleNoCliping(long x, long y, int radius, const RECT& rc, bool fill) { return Circle(x, y, radius, rc, false, fill); }
TEST(Circle, Length){ ASSERT_DOUBLE_EQ(Circle(Point(1,2),3).length(), 3. * 2 * M_PI ); };
void Bullet::draw(Game* game) { Circle(pos, size).draw(color); }
TEST(Circle, Intersection_Segment_1){ vector<Point> ans = { Point(sqrt(2.),sqrt(2.)) }; ASSERT_EQ(ans, Circle(Point(0,0),2).intersection(Segment(0,0,3,3))); };
/** * DXF round pad: always done in sketch mode; it could be filled but it isn't * pretty if other kinds of pad aren't... */ void DXF_PLOTTER::FlashPadCircle( const wxPoint& pos, int diametre, EDA_DRAW_MODE_T trace_mode, void* aData ) { wxASSERT( outputFile ); Circle( pos, diametre, NO_FILL ); }
Circle Plane::GenerateCircle(const vec &circleCenter, float radius) const { return Circle(Project(circleCenter), normal, radius); }
void ofApp::createNewParticle(){ Circle tempP = Circle(); //create a local Circle to pass into our vector which will store Circle objects circles.push_back(tempP); //add a new Circle to the rear of our vector }