igeo.gui
Class IPolyline2D

java.lang.Object
  extended by igeo.gui.IPolyline2D

public class IPolyline2D
extends java.lang.Object

2D polyline geometry to assist graphic classes of curves and surfaces.

Author:
Satoru Sugihara

Nested Class Summary
static class IPolyline2D.Intersection
           
static class IPolyline2D.XComparator
           
static class IPolyline2D.YComparator
           
 
Field Summary
 boolean closed
           
 IVec2 max
           
 IVec2 min
           
 IVec2[] pts
           
 
Constructor Summary
IPolyline2D()
           
IPolyline2D(int num)
           
IPolyline2D(IPolyline2D pl)
           
IPolyline2D(IVec2 pt)
           
IPolyline2D(IVec2[] pts)
           
IPolyline2D(IVec2 pt1, IVec2 pt2)
           
 
Method Summary
 void add(IVec2 pt)
           
 void append(IPolyline2D l)
           
 void append(IPolyline2D l, boolean reverseDir)
           
 void append(IVec2[] pts2)
           
 void append(IVec2[] pts2, boolean reverseDir)
           
 void checkBoundary()
           
 void close()
           
 IPolyline2D dup()
           
 IVec2 end()
           
 IVec2[] get()
           
 IVec2 get(int i)
           
 IVec2 getMaxBoundary()
           
 IVec2 getMinBoundary()
           
static IPolyline2D.Intersection[] getPairsInsidePolygon(IPolyline2D.Intersection[] pts, IVec2[] polygon, boolean xOrY)
           
 int indexOf(IVec2 pt)
           
 void insert(int idx, IVec2 pt)
           
 IVec2[] intersect(IPolyline2D line)
           
 IPolyline2D.Intersection[] intersectPolylineAndXLine(boolean inside, double y)
          gets intersection point with IPolyline2D instance and adjacent points
 IPolyline2D.Intersection[] intersectPolylineAndYLine(boolean inside, double x)
          gets intersection point with IPolyline2D instance and adjacent points
static IVec2I intersectXEdgeAndXLine(IVec2I pt1, IVec2I pt2, IVec2I pt3, IVec2I pt4, IVec2I intersectPt, boolean normalDir, boolean inside)
          when pt2 and pt3 are on X line, get a point which is inside/outisde intersection pt1 and pt4 can be null
static IVec2I intersectYEdgeAndYLine(IVec2I pt1, IVec2I pt2, IVec2I pt3, IVec2I pt4, IVec2I intersectPt, boolean normalDir, boolean inside)
          when pt2 and pt3 are on y line, get a point which is inside/outisde intersection pt1 and pt4 can be null
 boolean isClosed()
           
 boolean isNormalPositive()
           
static boolean isNormalPositive(IVec2I[] pts, boolean close)
          checking if the direction of closed polygon normal is positive towards z direction or not direction follows right screw law.
static IPolyline2D join(IPolyline2D[] lines, boolean close)
          join polylines without checking end points but removing end point of each line replaced with next start point
 int num()
           
 void open()
           
 void removeDuplicatedPoints()
           
 void removeStraightPoints()
           
 void reverse()
           
 void set(int i, IVec2 pt)
           
 void set(int i, IVec2I pt)
           
 IVec2 start()
           
static double sumOfExteriorAngles(IVec2I[] pts, boolean close)
           
 java.lang.String toString()
           
static IPolyline2D[] xLineInside(double y, IPolyline2D[] outlines, IPolyline2D[] holes)
           
static IPolyline2D[] yLineInside(double x, IPolyline2D[] outlines, IPolyline2D[] holes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pts

public IVec2[] pts

closed

public boolean closed

min

public IVec2 min

max

public IVec2 max
Constructor Detail

IPolyline2D

public IPolyline2D()

IPolyline2D

public IPolyline2D(int num)

IPolyline2D

public IPolyline2D(IVec2[] pts)

IPolyline2D

public IPolyline2D(IVec2 pt1,
                   IVec2 pt2)

IPolyline2D

public IPolyline2D(IVec2 pt)

IPolyline2D

public IPolyline2D(IPolyline2D pl)
Method Detail

dup

public IPolyline2D dup()

num

public int num()

get

public IVec2 get(int i)

start

public IVec2 start()

end

public IVec2 end()

get

public IVec2[] get()

set

public void set(int i,
                IVec2I pt)

set

public void set(int i,
                IVec2 pt)

indexOf

public int indexOf(IVec2 pt)

checkBoundary

public void checkBoundary()

getMinBoundary

public IVec2 getMinBoundary()

getMaxBoundary

public IVec2 getMaxBoundary()

isClosed

public boolean isClosed()

close

public void close()

open

public void open()

add

public void add(IVec2 pt)

insert

public void insert(int idx,
                   IVec2 pt)

append

public void append(IPolyline2D l)

append

public void append(IPolyline2D l,
                   boolean reverseDir)

append

public void append(IVec2[] pts2)

append

public void append(IVec2[] pts2,
                   boolean reverseDir)

reverse

public void reverse()

join

public static IPolyline2D join(IPolyline2D[] lines,
                               boolean close)
join polylines without checking end points but removing end point of each line replaced with next start point


intersect

public IVec2[] intersect(IPolyline2D line)

removeStraightPoints

public void removeStraightPoints()

removeDuplicatedPoints

public void removeDuplicatedPoints()

getPairsInsidePolygon

public static IPolyline2D.Intersection[] getPairsInsidePolygon(IPolyline2D.Intersection[] pts,
                                                               IVec2[] polygon,
                                                               boolean xOrY)

yLineInside

public static IPolyline2D[] yLineInside(double x,
                                        IPolyline2D[] outlines,
                                        IPolyline2D[] holes)

xLineInside

public static IPolyline2D[] xLineInside(double y,
                                        IPolyline2D[] outlines,
                                        IPolyline2D[] holes)

intersectXEdgeAndXLine

public static IVec2I intersectXEdgeAndXLine(IVec2I pt1,
                                            IVec2I pt2,
                                            IVec2I pt3,
                                            IVec2I pt4,
                                            IVec2I intersectPt,
                                            boolean normalDir,
                                            boolean inside)
when pt2 and pt3 are on X line, get a point which is inside/outisde intersection pt1 and pt4 can be null

Parameters:
pt1 - first point of polyline
pt2 - second point of polyline; pt2 and pt3 are both on the same x
pt3 - third point of polyline; pt2 and pt3 are both on the same x
pt4 - fourth point of polyline
intersectPt - intersecting point between pt2 and pt3
normalDir - direction of closing polygon if it's turning right screw direction or not
inside - getting inner or outer intersection point depending on normalDir

intersectYEdgeAndYLine

public static IVec2I intersectYEdgeAndYLine(IVec2I pt1,
                                            IVec2I pt2,
                                            IVec2I pt3,
                                            IVec2I pt4,
                                            IVec2I intersectPt,
                                            boolean normalDir,
                                            boolean inside)
when pt2 and pt3 are on y line, get a point which is inside/outisde intersection pt1 and pt4 can be null

Parameters:
pt1 - first point of polyline
pt2 - second point of polyline; pt2 and pt3 are both on the same y
pt3 - third point of polyline; pt2 and pt3 are both on the same y
pt4 - fourth point of polyline
intersectPt - intersecting point between pt2 and pt3
normalDir - direction of closing polygon if it's turning right screw direction or not
inside - getting inner or outer intersection point depending on normalDir

intersectPolylineAndXLine

public IPolyline2D.Intersection[] intersectPolylineAndXLine(boolean inside,
                                                            double y)
gets intersection point with IPolyline2D instance and adjacent points


intersectPolylineAndYLine

public IPolyline2D.Intersection[] intersectPolylineAndYLine(boolean inside,
                                                            double x)
gets intersection point with IPolyline2D instance and adjacent points


sumOfExteriorAngles

public static double sumOfExteriorAngles(IVec2I[] pts,
                                         boolean close)

isNormalPositive

public static boolean isNormalPositive(IVec2I[] pts,
                                       boolean close)
checking if the direction of closed polygon normal is positive towards z direction or not direction follows right screw law.


isNormalPositive

public boolean isNormalPositive()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object