fork download
  1. struct DPoint
  2. {
  3. float X;
  4. float Y;
  5. DPoint()
  6. {
  7. X = 0.0f;
  8. Y = 0.0f;
  9. }
  10. DPoint(float _X, float _Y)
  11. {
  12. X = _X;
  13. Y = _Y;
  14. }
  15. void swap(DPoint&a, DPoint&b)
  16. {
  17. std::swap(a.X ,b.X);
  18. std::swap(a.Y ,b.Y);
  19. }
  20. DPoint operator=(DPoint a)
  21. {
  22. DPoint::swap(*this,a);
  23. return *this;
  24. }
  25. };
  26.  
  27. bool operator<(DPoint const& a, DPoint const& b)
  28. {
  29. if(a.X >= b.X)return false;
  30. if(a.Y >= b.Y)return false;
  31. return true;
  32. }
  33.  
  34. bool operator>(DPoint const& a, DPoint const& b)
  35. {
  36. if(a.X <= b.X)return false;
  37. if(a.Y <= b.Y)return false;
  38. return true;
  39. }
  40.  
  41. bool operator==(DPoint const& a, DPoint const& b)
  42. {
  43. if(a.X != b.X)return false;
  44. if(a.Y != b.Y)return false;
  45. return true;
  46. }
  47.  
  48. bool operator==(DPoint const& a, float b)
  49. {
  50. if(a.X != b)return false;
  51. if(a.Y != b)return false;
  52. return true;
  53. }
  54.  
  55. bool operator==(float b,DPoint const& a)
  56. {
  57. if(a.X != b)return false;
  58. if(a.Y != b)return false;
  59. return true;
  60. }
  61.  
  62. DPoint operator-(DPoint const& a, DPoint const& b)
  63. {
  64. return DPoint(a.X-b.X,a.Y-b.Y);
  65. }
  66.  
  67. DPoint operator-(DPoint const& a, float b)
  68. {
  69. return DPoint(a.X-b,a.Y-b);
  70. }
  71.  
  72. DPoint operator-(float a, DPoint const& b)
  73. {
  74. return DPoint(a-b.X,a-b.Y);
  75. }
  76.  
  77. DPoint operator+(DPoint const& a, DPoint const& b)
  78. {
  79. return DPoint(a.X+b.X,a.Y+b.Y);
  80. }
  81.  
  82. DPoint operator+(DPoint const& a, float b)
  83. {
  84. return DPoint(a.X+b,a.Y+b);
  85. }
  86.  
  87. DPoint operator+(float a, DPoint const& b)
  88. {
  89. return DPoint(a+b.X,a+b.Y);
  90. }
  91.  
  92. DPoint operator/(DPoint const& a, DPoint const& b)
  93. {
  94. return DPoint(a.X/b.X,a.Y/b.Y);
  95. }
  96.  
  97. DPoint operator/(DPoint const& a, float b)
  98. {
  99. return DPoint(a.X/b,a.Y/b);
  100. }
  101.  
  102. DPoint operator/(float a, DPoint const& b)
  103. {
  104. return DPoint(a/b.X,a/b.Y);
  105. }
  106.  
  107. DPoint operator*(DPoint const& a, DPoint const& b)
  108. {
  109. return DPoint(a.X*b.X,a.Y*b.Y);
  110. }
  111.  
  112. DPoint operator*(DPoint const& a, float b)
  113. {
  114. return DPoint(a.X*b,a.Y*b);
  115. }
  116.  
  117. DPoint operator*(float a, DPoint const& b)
  118. {
  119. return DPoint(a*b.X,a*b.Y);
  120. }
  121.  
  122. DPoint function_u(DPoint input)
  123. {
  124. return input / (sqrt((input.X * input.X) + (input.Y * input.Y))); // (1)
  125. }
  126.  
  127. DPoint function_r(DPoint input)
  128. {
  129. return function_u(DPoint(input.Y, -input.X)); // (2)
  130. }
  131. vector <cell> PolygonTemp;
  132.  
  133.  
  134. //somewhere here
  135.  
  136. DPoint temp[4];
  137. temp[0] = DPoint(Thread_xNode[tbcway.at(0)].xPOS,Thread_xNode[tbcway.at(0)].yPOS);
  138. temp[1] = DPoint(Thread_xNode[tbcway.at(1)].xPOS,Thread_xNode[tbcway.at(1)].yPOS);
  139.  
  140. temp[2] = temp[0] - (function_r(temp[1] - temp[0]) * RecievedData.Width);
  141. temp[3] = temp[0] + (function_r(temp[1] - temp[0]) * RecievedData.Width);
  142.  
  143. PolygonTemp.push_back(amx_ftoc(temp[2].X));
  144. PolygonTemp.push_back(amx_ftoc(temp[2].Y));
  145. PolygonTemp.push_back(amx_ftoc(temp[3].X));
  146. PolygonTemp.push_back(amx_ftoc(temp[3].Y));
  147.  
  148. for(unsigned int k = 1; k < tbcway.size(); ++k)
  149. {
  150. temp[0] = DPoint(Thread_xNode[tbcway.at(k)].xPOS,Thread_xNode[tbcway.at(k)].yPOS);
  151. temp[1] = DPoint(Thread_xNode[tbcway.at(k+1)].xPOS,Thread_xNode[tbcway.at(k+1)].yPOS);
  152. temp[2] = DPoint(Thread_xNode[tbcway.at(k-1)].xPOS,Thread_xNode[tbcway.at(k-1)].yPOS);
  153.  
  154. temp[3] = temp[0] + (function_r(function_u(temp[1] - temp[0]) - function_u(temp[2] - temp[0])) * RecievedData.Width);
  155.  
  156. PolygonTemp.push_back(amx_ftoc(temp[3].X));
  157. PolygonTemp.push_back(amx_ftoc(temp[3].Y));
  158. }
  159.  
  160. temp[0] = DPoint(Thread_xNode[tbcway.at(tbcway.size()-1)].xPOS,Thread_xNode[tbcway.at(tbcway.size()-1)].yPOS);
  161. temp[1] = DPoint(Thread_xNode[tbcway.at(tbcway.size()-2)].xPOS,Thread_xNode[tbcway.at(tbcway.size()-2)].yPOS);
  162.  
  163. temp[2] = temp[0] - (function_r(temp[1] - temp[0]) * RecievedData.Width);
  164. temp[3] = temp[0] + (function_r(temp[1] - temp[0]) * RecievedData.Width);
  165.  
  166. PolygonTemp.push_back(amx_ftoc(temp[2].X));
  167. PolygonTemp.push_back(amx_ftoc(temp[2].Y));
  168. PolygonTemp.push_back(amx_ftoc(temp[3].X));
  169. PolygonTemp.push_back(amx_ftoc(temp[3].Y));
  170.  
  171. for(int k = tbcway.size()-1; k > 0; --k)
  172. {
  173. temp[0] = DPoint(Thread_xNode[tbcway.at(k)].xPOS,Thread_xNode[tbcway.at(k)].yPOS);
  174. temp[1] = DPoint(Thread_xNode[tbcway.at(k+1)].xPOS,Thread_xNode[tbcway.at(k+1)].yPOS);
  175. temp[2] = DPoint(Thread_xNode[tbcway.at(k-1)].xPOS,Thread_xNode[tbcway.at(k-1)].yPOS);
  176.  
  177. temp[3] = temp[0] - (function_r(function_u(temp[1] - temp[0]) - function_u(temp[2] - temp[0])) * RecievedData.Width);
  178.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty