Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.7 KiB

  1. /**************************************************************************
  2. *
  3. * Copyright (c) 2000 Microsoft Corporation
  4. *
  5. * Module Name:
  6. *
  7. * Cycloid Drawing.
  8. *
  9. * Abstract:
  10. *
  11. * Routines for computing and drawing cycloids.
  12. *
  13. * Created:
  14. *
  15. * 06/11/2000 asecchia
  16. * Created it.
  17. *
  18. **************************************************************************/
  19. #include "drawcycloid.hpp"
  20. /**************************************************************************
  21. *
  22. * Function Description:
  23. *
  24. * Test function to draw an example cycloid.
  25. *
  26. * Created:
  27. *
  28. * 06/11/2000 asecchia
  29. * Created it.
  30. *
  31. **************************************************************************/
  32. void DrawTestCycloid(Graphics *g, int a, int b, int width, int height)
  33. {
  34. #define _2PI 2*3.141592653689
  35. // Compute the center point for the cycle.
  36. float fXo=static_cast<float>(width)/2.0f;
  37. float fYo=static_cast<float>(height)/2.0f;
  38. float ScaleX = fXo/( (a>b)?a:a+b );
  39. float ScaleY = fYo/( (a>b)?a:a+b );
  40. int cycle=b/gcf(a,b); //number of times round the outer circle
  41. int Num = cycle*30;
  42. PointF *points = new PointF[Num];
  43. // Compute the points tracking the cycloid path.
  44. for(int i=0; i<Num; i++)
  45. {
  46. float t = (float)(cycle*_2PI*i/Num);
  47. points[i].X = 10+(float)(fXo+ScaleX*((a-b)*cos(t)+b*cos((a-b)*t/b)));
  48. points[i].Y = 10+(float)(fYo+ScaleY*((a-b)*sin(t)-b*sin((a-b)*t/b)));
  49. }
  50. Color PenColor(0xffff0000);
  51. Pen myPen(PenColor, 2.0f);
  52. myPen.SetLineJoin(LineJoinBevel);
  53. g->DrawPolygon(&myPen, points, Num);
  54. #undef _2PI
  55. }