summaryrefslogtreecommitdiff
path: root/src/fl_arc.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/fl_arc.cxx')
-rw-r--r--src/fl_arc.cxx52
1 files changed, 23 insertions, 29 deletions
diff --git a/src/fl_arc.cxx b/src/fl_arc.cxx
index f234711f3..58857c811 100644
--- a/src/fl_arc.cxx
+++ b/src/fl_arc.cxx
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
// Arc functions for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2016 by Bill Spitzak and others.
@@ -9,11 +7,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
/**
@@ -28,7 +26,7 @@
#include <FL/fl_draw.H>
#include <FL/math.h>
-// avoid problems with some platforms that don't
+// avoid problems with some platforms that don't
// implement hypot.
static double _fl_hypot(double x, double y) {
return sqrt(x*x + y*y);
@@ -52,35 +50,35 @@ static double _fl_hypot(double x, double y) {
void Fl_Graphics_Driver::arc(double x, double y, double r, double start, double end) {
// draw start point accurately:
-
- double A = start*(M_PI/180); // Initial angle (radians)
- double X = r*cos(A); // Initial displacement, (X,Y)
- double Y = -r*sin(A); // from center to initial point
- fl_vertex(x+X,y+Y); // Insert initial point
+
+ double A = start*(M_PI/180); // Initial angle (radians)
+ double X = r*cos(A); // Initial displacement, (X,Y)
+ double Y = -r*sin(A); // from center to initial point
+ fl_vertex(x+X,y+Y); // Insert initial point
// Maximum arc length to approximate with chord with error <= 0.125
-
+
double epsilon; {
double r1 = _fl_hypot(fl_transform_dx(r,0), // Horizontal "radius"
- fl_transform_dy(r,0));
+ fl_transform_dy(r,0));
double r2 = _fl_hypot(fl_transform_dx(0,r), // Vertical "radius"
- fl_transform_dy(0,r));
-
- if (r1 > r2) r1 = r2; // r1 = minimum "radius"
- if (r1 < 2.) r1 = 2.; // radius for circa 9 chords/circle
-
- epsilon = 2*acos(1.0 - 0.125/r1); // Maximum arc angle
+ fl_transform_dy(0,r));
+
+ if (r1 > r2) r1 = r2; // r1 = minimum "radius"
+ if (r1 < 2.) r1 = 2.; // radius for circa 9 chords/circle
+
+ epsilon = 2*acos(1.0 - 0.125/r1); // Maximum arc angle
}
- A = end*(M_PI/180) - A; // Displacement angle (radians)
- int i = int(ceil(fabs(A)/epsilon)); // Segments in approximation
-
+ A = end*(M_PI/180) - A; // Displacement angle (radians)
+ int i = int(ceil(fabs(A)/epsilon)); // Segments in approximation
+
if (i) {
- epsilon = A/i; // Arc length for equal-size steps
- double cos_e = cos(epsilon); // Rotation coefficients
+ epsilon = A/i; // Arc length for equal-size steps
+ double cos_e = cos(epsilon); // Rotation coefficients
double sin_e = sin(epsilon);
do {
double Xnew = cos_e*X + sin_e*Y;
- Y = -sin_e*X + cos_e*Y;
+ Y = -sin_e*X + cos_e*Y;
fl_vertex(x + (X=Xnew), y + Y);
} while (--i);
}
@@ -90,7 +88,3 @@ void Fl_Graphics_Driver::arc(double x, double y, double r, double start, double
\}
\endcond
*/
-
-//
-// End of "$Id$".
-//