Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1B9249A57 for ; Sun, 2 Jun 2013 13:09:25 +0000 (UTC) Received: (qmail 53153 invoked by uid 500); 2 Jun 2013 13:09:21 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 52956 invoked by uid 500); 2 Jun 2013 13:09:21 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 52896 invoked by uid 99); 2 Jun 2013 13:09:21 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Jun 2013 13:09:21 +0000 Date: Sun, 2 Jun 2013 13:09:21 +0000 (UTC) From: "Andreas Huber (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (MATH-988) NPE when calling SubLine.intersection() with non-intersecting lines MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/MATH-988?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Andreas Huber updated MATH-988: ------------------------------- Attachment: SubLineIntersection.patch This patch fixes both implementations and adds test cases. > NPE when calling SubLine.intersection() with non-intersecting lines > ------------------------------------------------------------------- > > Key: MATH-988 > URL: https://issues.apache.org/jira/browse/MATH-988 > Project: Commons Math > Issue Type: Bug > Affects Versions: 3.0, 3.1, 3.2, 3.1.1 > Reporter: Andreas Huber > Attachments: SubLineIntersection.patch > > > When calling SubLine.intersection() with two lines that not intersect, then a NullPointerException is thrown in Line.toSubSpace(). This bug is in the twod and threed implementations. > The following patch fixes both implementations and adds the required test cases: > Index: src/test/java/org/apache/commons/math3/geometry/euclidean/threed/SubLineTest.java > =================================================================== > --- src/test/java/org/apache/commons/math3/geometry/euclidean/threed/SubLineTest.java (revision 1488671) > +++ src/test/java/org/apache/commons/math3/geometry/euclidean/threed/SubLineTest.java (working copy) > @@ -152,5 +152,13 @@ > Assert.assertNull(sub1.intersection(sub2, true)); > Assert.assertNull(sub1.intersection(sub2, false)); > } > + > + @Test > + public void testIntersectionNotIntersecting() throws MathIllegalArgumentException { > + SubLine sub1 = new SubLine(new Vector3D(1, 1, 1), new Vector3D(1.5, 1, 1)); > + SubLine sub2 = new SubLine(new Vector3D(2, 3, 0), new Vector3D(2, 3, 0.5)); > + Assert.assertNull(sub1.intersection(sub2, true)); > + Assert.assertNull(sub1.intersection(sub2, false)); > + } > > } > Index: src/test/java/org/apache/commons/math3/geometry/euclidean/twod/SubLineTest.java > =================================================================== > --- src/test/java/org/apache/commons/math3/geometry/euclidean/twod/SubLineTest.java (revision 1488671) > +++ src/test/java/org/apache/commons/math3/geometry/euclidean/twod/SubLineTest.java (working copy) > @@ -144,4 +144,12 @@ > Assert.assertNull(sub1.intersection(sub2, false)); > } > > + @Test > + public void testIntersectionParallel() > + { > + final SubLine sub1 = new SubLine(new Vector2D(0, 1), new Vector2D(0, 2)); > + final SubLine sub2 = new SubLine(new Vector2D(66, 3), new Vector2D(66, 4)); > + Assert.assertNull(sub1.intersection(sub2, true)); > + Assert.assertNull(sub1.intersection(sub2, false)); > + } > } > Index: src/main/java/org/apache/commons/math3/geometry/euclidean/threed/SubLine.java > =================================================================== > --- src/main/java/org/apache/commons/math3/geometry/euclidean/threed/SubLine.java (revision 1488671) > +++ src/main/java/org/apache/commons/math3/geometry/euclidean/threed/SubLine.java (working copy) > @@ -111,6 +111,10 @@ > > // compute the intersection on infinite line > Vector3D v1D = line.intersection(subLine.line); > + if (v1D == null) > + { > + return null; > + } > > // check location of point with respect to first sub-line > Location loc1 = remainingRegion.checkPoint(line.toSubSpace(v1D)); > Index: src/main/java/org/apache/commons/math3/geometry/euclidean/twod/SubLine.java > =================================================================== > --- src/main/java/org/apache/commons/math3/geometry/euclidean/twod/SubLine.java (revision 1488671) > +++ src/main/java/org/apache/commons/math3/geometry/euclidean/twod/SubLine.java (working copy) > @@ -115,6 +115,10 @@ > > // compute the intersection on infinite line > Vector2D v2D = line1.intersection(line2); > + if (v2D == null) > + { > + return null; > + } > > // check location of point with respect to first sub-line > Location loc1 = getRemainingRegion().checkPoint(line1.toSubSpace(v2D)); -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira