From: dooglus Date: Wed, 2 Apr 2008 12:36:03 +0000 (+0000) Subject: Avoid division by zero when approximating a circle by two points. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=8f58d98b60c5b3662a9037dcba1dac6203b04d72;p=synfig.git Avoid division by zero when approximating a circle by two points. git-svn-id: http://svn.voria.com/code@1954 1f10aa63-cdf2-0310-b900-c93c546f37ac --- diff --git a/synfig-studio/trunk/src/gtkmm/state_circle.cpp b/synfig-studio/trunk/src/gtkmm/state_circle.cpp index f501d16..baf6786 100644 --- a/synfig-studio/trunk/src/gtkmm/state_circle.cpp +++ b/synfig-studio/trunk/src/gtkmm/state_circle.cpp @@ -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 new_list;