[comp.lang.postscript] Another patch for HPGL to PostScript

federico@actisb.UUCP (Federico Heinz) (02/10/89)

  Please apply this patch to the yahp2ps program I posted about a month
ago.  It fixes a problem computing the radius of circles when the start
angle is near a square angle.

--------------------------------- Cut Here --------------------------------
*** circle.alt	Thu Feb  9 19:12:10 1989
--- circle.c	Thu Feb  9 19:24:09 1989
***************
*** 328,340 ****
  Number *radius, *angle;
  CoordinatePair offset;
  
! { Number cosineOfAngle;
  
    *angle = arcTangent(offset);
!   if (cosineOfAngle = cosine(*angle))	/* Watch out for cos(a) == 0!!! */
!     *radius = divNum(offset[X], cosineOfAngle);
    else
!     *radius = offset[X] ? offset[X] : offset[Y];
    if (*radius < 0) *radius = -*radius;
  }
  
--- 328,347 ----
  Number *radius, *angle;
  CoordinatePair offset;
  
! {
!   Number Xabs, Yabs;
  
+   Xabs = abs(offset[X]);
+   Yabs = abs(offset[Y]);
    *angle = arcTangent(offset);
!   if (!offset[X])
!     *radius = Yabs;
!   else if (!offset[Y])
!     *radius = Xabs;
!   else if (Xabs > Yabs)
!     *radius = divNum(offset[X], cosine(*angle));
    else
!     *radius = divNum(offset[Y], sine(*angle));
    if (*radius < 0) *radius = -*radius;
  }
  
-------------------------- Cut Here -----------------------------------

Have fun

-- 
		Federico Heinz     "I can resist anything but temptation"
                                        -- Oscar Wilde
 From Europe:   ...!mcvax!unido!tub!actisb!federico
 From elsewhere: ...!uunet!pyramid!/