Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4269809

Line2D relativeCCW() returns opposite of what documentation says

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.3.1
    • 1.2.2
    • docs
    • beta
    • generic
    • generic



        Name: wl91122 Date: 09/08/99


        import java.awt.geom.*;
        /**
         * This program demonstrates an inconsistency between the
         * documentation and the implementation of java.awt.geom.Line2D
         * in JDK 1.2.2.
         *
         * Specifically, the relativeCCW() method returns the negative
         * value of what it should return.
         *
         * Bill Farrior
         * September 7, 1999
         * ###@###.###
         */
        public class LineBug {

          public static void main(String args[])
          {
            System.out.println("Consider a line segment from p0 (0,0) to p1 (1,0).\n"+
            "A point P lies at (0,2).\n\n" +
            "For the line segment to \"point at\" the specified point, it must turn\n"+
            "counterclockwise 90 degrees about its first point at the origin.\n"+
            "According to the documention on Class java.awt.geom.Line2D, the\n"+
            "relativeCCW() method should rightfully return a postive 1 in this\n"+
            "situation."
            );

            System.out.println("\nHowever, the actual value returned is as follows:");

            // Define p0
            Point2D.Double p0 = new Point2D.Double(0,0);
            System.out.println("p0 = " + p0);

            // Define p1
            Point2D.Double p1 = new Point2D.Double(1,0);
            System.out.println("p1 = " + p1);

            // Define a line from p0 to p1
            Line2D.Double line = new Line2D.Double(p0,p1);
            System.out.println("line created from p0 to p1.");

            // Define p
            Point2D.Double p = new Point2D.Double(0,2);
            System.out.println("p = " + p);

            // Print the flawed result
            System.out.println("line.relativeCCW(p) = " + line.relativeCCW(p) );
          }
        }
        (Review ID: 94985)
        ======================================================================

              jballsunw Jennifer Ball (Inactive)
              wleesunw William Lee (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: