[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: pcb.git: branch: master updated (77785825fc7fe8a69401dd5d8f856b4425a6b0f2)



The branch, master has been updated
       via  77785825fc7fe8a69401dd5d8f856b4425a6b0f2 (commit)
      from  c7bc8afec69a3b534714fbe360deaef4e8819215 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 src/hid/common/hidgl.c |   17 +++++------------
 1 files changed, 5 insertions(+), 12 deletions(-)


=================
 Commit Messages
=================

commit 77785825fc7fe8a69401dd5d8f856b4425a6b0f2
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    hid/common/hidgl.c: Simplify angle calculation for drawing line caps
    
    Make use of atan2 to avoid special casing horizontal lines, and move
    make the input variables doubles to be consistent with that function.
    Our use of "tanl" was inappropriate for the float input, dobule output
    variables we were using before (spotted by Dan McMahill).
    
    I have modified the semantic meaning of angle, to keep the more
    conventional angle = atan2 (dy, dx); geometry. This means the angle
    now refers to the angle of the line, not the angle of the line-cap
    start. (The angle is adjusted before passing into the cap drawing
    routines).

:100644 100644 7ec148f... 15273a6... M	src/hid/common/hidgl.c

=========
 Changes
=========

commit 77785825fc7fe8a69401dd5d8f856b4425a6b0f2
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    hid/common/hidgl.c: Simplify angle calculation for drawing line caps
    
    Make use of atan2 to avoid special casing horizontal lines, and move
    make the input variables doubles to be consistent with that function.
    Our use of "tanl" was inappropriate for the float input, dobule output
    variables we were using before (spotted by Dan McMahill).
    
    I have modified the semantic meaning of angle, to keep the more
    conventional angle = atan2 (dy, dx); geometry. This means the angle
    now refers to the angle of the line, not the angle of the line-cap
    start. (The angle is adjusted before passing into the cap drawing
    routines).

diff --git a/src/hid/common/hidgl.c b/src/hid/common/hidgl.c
index 7ec148f..15273a6 100644
--- a/src/hid/common/hidgl.c
+++ b/src/hid/common/hidgl.c
@@ -215,7 +215,7 @@ void
 hidgl_draw_line (int cap, Coord width, Coord x1, Coord y1, Coord x2, Coord y2, double scale)
 {
   double angle;
-  float deltax, deltay, length;
+  double deltax, deltay, length;
   float wdx, wdy;
   int circular_caps = 0;
   int hairline = 0;
@@ -233,7 +233,6 @@ hidgl_draw_line (int cap, Coord width, Coord x1, Coord y1, Coord x2, Coord y2, d
 
   if (length == 0) {
     /* Assume the orientation of the line is horizontal */
-    angle = 0;
     wdx = -width / 2.;
     wdy = 0;
     length = 1.;
@@ -242,16 +241,10 @@ hidgl_draw_line (int cap, Coord width, Coord x1, Coord y1, Coord x2, Coord y2, d
   } else {
     wdy = deltax * width / 2. / length;
     wdx = -deltay * width / 2. / length;
-
-    if (deltay == 0.)
-      angle = (deltax < 0) ? 270. : 90.;
-    else
-      angle = 180. / M_PI * atanl (deltax / deltay);
-
-    if (deltay < 0)
-      angle += 180.;
   }
 
+  angle = -180. / M_PI * atan2 (deltay, deltax);
+
   switch (cap) {
     case Trace_Cap:
     case Round_Cap:
@@ -278,8 +271,8 @@ hidgl_draw_line (int cap, Coord width, Coord x1, Coord y1, Coord x2, Coord y2, d
   /* Don't bother capping hairlines */
   if (circular_caps && !hairline)
     {
-      draw_cap (width, x1, y1, angle, scale);
-      draw_cap (width, x2, y2, angle + 180., scale);
+      draw_cap (width, x1, y1, angle + 90., scale);
+      draw_cap (width, x2, y2, angle - 90., scale);
     }
 }
 




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs