double rad, t;\r
double x, y, v;\r
double ix, iy, ia, ib, ir;\r
- int ox1, oy1, ox2, oy2;\r
int count, tt;\r
int delta;\r
double deltad;\r
\r
//line SUICHOKU by vector\r
if(ix != 0 && iy != 0){\r
- ir = atan(iy / ix * -1.0);\r
+ ir = atan(iy / ix * -1);\r
ia = sin(ir) * (double)(kMinWidthT);\r
ib = cos(ir) * (double)(kMinWidthT);\r
}\r
ia = ia * deltad;\r
ib = ib * deltad;\r
\r
- //swap if two lines are crossing\r
- if(((x + ia) - ox1) * ((x + ia) - ox1) +\r
- ((y + ib) - oy1) * ((y + ib) - oy1) >\r
- ((x - ia) - ox1) * ((x - ia) - ox1) +\r
- ((y - ib) - oy1) * ((y - ib) - oy1) && count != 0){\r
- ia = ia * -1;\r
- ib = ib * -1;\r
+ //reverse if vector is going 2nd/3rd quadrants\r
+ if(ix <= 0){\r
+ ia = ia * -1;\r
+ ib = ib * -1;\r
}\r
\r
- //copy as an old point\r
- ox1 = x + ia;\r
- oy1 = y + ib;\r
- ox2 = x - ia;\r
- oy2 = y - ib;\r
- \r
//copy to polygon structuer\r
- poly[count].X = x + ia;\r
- poly[count].Y = y + ib;\r
- poly[(1000 / kRate + 1) * 2 - 1 - count].X = x - ia;\r
- poly[(1000 / kRate + 1) * 2 - 1 - count].Y = y - ib;\r
+ poly[count].X = x - ia;\r
+ poly[count].Y = y - ib;\r
+ poly[(1000 / kRate + 1) * 2 - 1 - count].X = x + ia;\r
+ poly[(1000 / kRate + 1) * 2 - 1 - count].Y = y + ib;\r
count += 1;\r
}\r
\r
ib = kWidth;\r
}\r
}\r
- \r
- //if it is crossing, swap each other\r
- if(((x + ia) - ox1) * ((x + ia) - ox1) +\r
- ((y + ib) - oy1) * ((y + ib) - oy1) >\r
- ((x - ia) - ox1) * ((x - ia) - ox1) +\r
- ((y - ib) - oy1) * ((y - ib) - oy1) && count != 0){\r
- ia = ia * -1;\r
- ib = ib * -1;\r
+\r
+ //reverse if vector is going 2nd/3rd quadrants\r
+ if(ix <= 0){\r
+ ia = ia * -1;\r
+ ib = ib * -1;\r
}\r
- \r
- //save old points for calculate crossing\r
- ox1 = x + ia;\r
- oy1 = y + ib;\r
- ox2 = x - ia;\r
- oy2 = y - ib;\r
- \r
+ \r
//save to polygon\r
- poly[count].X = x + ia;\r
- poly[count].Y = y + ib;\r
- poly[(1000 / kRate + 1) * 2 - 1 - count].X = x - ia;\r
- poly[(1000 / kRate + 1) * 2 - 1 - count].Y = y - ib;\r
+ poly[count].X = x - ia;\r
+ poly[count].Y = y - ib;\r
+ poly[(1000 / kRate + 1) * 2 - 1 - count].X = x + ia;\r
+ poly[(1000 / kRate + 1) * 2 - 1 - count].Y = y + ib;\r
count += 1;\r
}\r
\r
if(a1 % 10 == 3){ y1 = y1 - kWidth * kKakato; }\r
if(a2 % 10 == 3){ y2 = y2 + kWidth * kKakato; }\r
\r
- poly[0].X = x1 - kWidth;\r
- poly[0].Y = y1;\r
- poly[1].X = x2 - kWidth;\r
- poly[1].Y = y2;\r
- poly[2].X = x2 + kWidth;\r
- poly[2].Y = y2;\r
- poly[3].X = x1 + kWidth;\r
+ poly[3].X = x1 - kWidth;\r
poly[3].Y = y1;\r
+ poly[2].X = x2 - kWidth;\r
+ poly[2].Y = y2;\r
+ poly[1].X = x2 + kWidth;\r
+ poly[1].Y = y2;\r
+ poly[0].X = x1 + kWidth;\r
+ poly[0].Y = y1;\r
\r
icPolygon(poly, 4);\r
}\r