Avoid division by zero when approximating a circle by two points.
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Wed, 2 Apr 2008 12:36:03 +0000 (12:36 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Wed, 2 Apr 2008 12:36:03 +0000 (12:36 +0000)
git-svn-id: http://svn.voria.com/code@1954 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-studio/trunk/src/gtkmm/state_circle.cpp

index f501d16..baf6786 100644 (file)
@@ -519,7 +519,9 @@ StateCircle_Context::make_circle(const Point& _p1, const Point& _p2)
        Real radius((p2-p1).mag());
        int points = get_number_of_bline_points();
        Angle::deg angle(360.0/points);
-       Real tangent(4 * (2 * Angle::cos(angle/2).get() - Angle::cos(angle).get() - 1) / Angle::sin(angle).get());
+       Real tangent(4 * ((points == 2)
+                                         ? 1
+                                         : ((2 * Angle::cos(angle/2).get() - Angle::cos(angle).get() - 1) / Angle::sin(angle).get())));
        Real x(p1[0]), y(p1[1]);
 
        std::vector<BLinePoint> new_list;