diff --git a/main_path.cpp b/main_path.cpp index 3986b01..fa90f6a 100644 --- a/main_path.cpp +++ b/main_path.cpp @@ -60,7 +60,7 @@ double get_angle(Point start, Point end) if (vec.y < 0) { - angle += 180.0; + angle = 360 - angle; } return angle; @@ -89,9 +89,28 @@ pair perform_stroke(double stroke_size, double stroke_angle, Point return result; } +pair perform_stroke(double stroke_size, double prev_angle, double curr_angle, Point point) +{ + pair result; + Point add; + double stroke_angle; + double extra_angle; + + extra_angle = (curr_angle - prev_angle) / 2 + 90.0; + stroke_angle = extra_angle + prev_angle; + + add.x = cos(radians(stroke_angle)) * stroke_size / 2 / sin(radians(extra_angle)); + add.y = sin(radians(stroke_angle)) * stroke_size / 2 / sin(radians(extra_angle)); + + result.first = point + add; + result.second = point - add; + + return result; +} + void usage(const string& name) { - cout << "Usage: " << name << " [ ...]" << endl; + cout << "Usage: " << name << " [ ...]" << endl; cout << "\tstroke size - how big the stroke should be" << endl; cout << "\tx1 - x coordinate of first point" << endl; cout << "\ty1 - y coordinate of first point" << endl; @@ -117,7 +136,7 @@ void get_polygon(double stroke_size, const vector& points) } else { - tmp = perform_stroke(stroke_size, get_stroke_angle(prev_angle, curr_angle), points[i - 1]); + tmp = perform_stroke(stroke_size, prev_angle, curr_angle, points[i - 1]); } forward.push_back(tmp.first);