Java Drawing Test Codes Intersection between two arbitrary curves
2010.9.01

Language

Topics

Mouse hit test for a closed shape
2010.08.26


Mouse hit test for an unclosed shape
2010.08.26


Intersection between two arbitrary curves
2010.09.01


Normal lines to a arbitrary curve
2010.09.01


Common normal lines between two shapes
2016.10.20


Text Editor using the Input Method Framework
2010.12.01


Component Library
2012.09.16


Costom Color Chooser
2012.9.23



Chapter: 1. Source code download, 2. Test results, 3. Test item and method, 4. Test code

1. Source code download

=> IntersectionPts.zip



2. Test resultsreturn=>page top

Figure1 Results of the intersection points calculation between two curves

: Similar test => DrawTop test command

Operation video
GeometricTest


3. Test item and method return=>page top
Intersection points between two curves are calculated by the Curve2DUtil.getIntersectionPts method.
The reliability and the processing speed of the above method are tested. The test is performed under the severe condition in which either curve nearly contacts with another curve. Such a severe condition may be created by translating either curve repeatedly.

public static CrossCurvePT[] get IntersectionPts(Curve2D curve1, Curve2D curve2)
Parameters:

curve1 - The Curve2D object of the first (parametric) curve.
curve2 - The Curve2D object of the second (parametric) curve.

Returns:

The array of the CrossCurvePT objects which represents the intersection points of the curve1 and curve2. If there is no intersection, then returns the array of 0-length.



4. Test code return=>page top


4.1 Classes Overview

Class

Description

IntersectionPt

public class IntersectionPts extends JFrame
Creates and assembles the objects of the Jframe, JScrollPane, JViewport and the Panel.

IntersectionPtsPanel

public class IntersectionPtsPanel extends JPanel

Draws curves and intersection points on this panel.

TestCase public class TestCase
=> TestCase of the RegionHitTest.
TestCurve public class TestCurve
=> TestCurve of the RegionHitTest.
Parametric Curves Segment2D, Curve2D, Rectangle2DE, RoundRectangle2DE, Ellipse2DE, Line2DE, Polyline2DE,
CubicCurve2DE, GeneralCurve2DE, FergusonCurve2D
Geometric library Curve2DUtil.getIntersectionPts, CrossCurvePT, Matrix, Matrix2D


4.2 Specifications return=>page top
4.2.1 public class IntersectionPTsPanel extends JPanel

Method

Description

createTestCase

public void createTestCase()

Creates TastCase objects.

paint

public void paint(Graphics g)

Draws the curves specified by the TestCase objects and the intersection points on this panel.
Intersection points between two curves are calculated by the Curve2DUtil.getIntersectionPts method and they are output as the array of CrossCurvePT objects.


Copyright (c) 2009-2013
All other trademarks are property of their respective owners.