Java Drawing Test Codes Normal lines to a 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

=> NormalLines.zip, ShortestNormalLines.zip



2. Test results return=>page top

Figure1 Normal lines from a point to curves(NormalLines)
The normal Lines to a curve from a point are generally multiple,
so we distinguish the lines by their colors such as red, magenta, green and so on.

Figure2 Shotest normal lines from a point to curves(ShortestNormalLines)
The calculation of the shortest noramal line to a curve from a point is equal to that of the closest point on the curve from the point.


: Similar test => DrawTop test command

Operation video
GeometricTest
3. Test item and method return=>page top

The methods to calculate the normal lines from a given point to a curve are Curve2DUtil.getNormalLines and Curve2DUtil.getShortestNormalLine.
These methods are used for shape selection operation with clicking the mouse, so the processing speed is important for real-time operation. Of course, the reliability is also important.

public static CurvePT[] getNormalLines(Point2D point, Curve2D curve)
Parameters:

point - The given point.
curve - The Curve2D object of the (parametric) curve.

Returns:

The array of the CurvePT objects representing the points on the curve. If the normal lines to the curve are found, the getNormalLines method returns the array of the points (stored in the CurvePT objects) which are the endpoints of the lines and lying on the curve, otherwise retunets the array of 0-length



4. Test code return=>page top

4.1 Classes Overview
4.1.1 NormalLines

Class

Description

NormalLines

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

NormalLinesPanel

public class NormalLinesPanel extends JPanel

Draws curves and normal lines 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.getNormalLines, Curve2DUtil.getShortestNormalLine, CurvePT, Matrix, Matrix2D

4.1.2 ShortestNormalLines

Class

Description

ShortestNormalLines

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

ShortestNormalLinesPanel

public class ShortestNormalLinesPanel extends JPanel

Draws curves and normal lines on this panel.

TestCase public class TestCase
=> TestCase of the RegionHitTest.
TestCurve public class TestCurve
=> TestCurve of the RegionHitTest.
Parametric Curves The same as NormalLines.
Geometric Library The same as NormalLines.


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

Method

Description

createTestCase

public void createTestCase()

Creates TastCase objects.

paint public void paint(Graphics g)
Draws the curves and the normal lines on this object shown as Figure1.
The calculation of the normal lines from a given point to a curves is performed by Curve2DUtil.getNormalLines method.

4.2.2 public class ShortestNormalLinesPanel extends JPanel

Method

Description

createTestCase

public void createTestCase()

Creates TastCase objects.

paint public void paint(Graphics g)
Draws the curves and the normal lines on this object shown as Figure2.
The calculation of the shortest normal lines from a given point to a curves is performed by the Curve2DUtil.getShortestNormalLine method.


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