us.ihmc.utilities.math.geometry
Class FrameConvexPolygon2d

java.lang.Object
  extended by us.ihmc.utilities.math.geometry.FrameConvexPolygon2d
All Implemented Interfaces:
FrameGeometry2d, ReferenceFrameHolder

public class FrameConvexPolygon2d
extends java.lang.Object
implements ReferenceFrameHolder, FrameGeometry2d

Title:

Description:

Copyright: Copyright (c) 2007

Company:

Version:
1.0
Author:
IHMC-Yobotics Biped Team

Constructor Summary
FrameConvexPolygon2d(java.util.Collection<FramePoint2d> framePointList)
           
FrameConvexPolygon2d(FrameConvexPolygon2d frameConvexPolygon2d)
           
FrameConvexPolygon2d(ReferenceFrame referenceFrame, ConvexPolygon2d convexPolygon2d)
           
FrameConvexPolygon2d(ReferenceFrame referenceFrame, double[][] pointList)
           
FrameConvexPolygon2d(ReferenceFrame referenceFrame, java.util.List<javax.vecmath.Point2d> pointList)
           
 
Method Summary
 FrameConvexPolygon2d applyTransformCopy(javax.media.j3d.Transform3D transform, ReferenceFrame newFrame, boolean requirePlanarTransform)
          applyTransformCopy Use of this method is discouraged.
 boolean areAllPointsInside(FramePoint2d[] framePoints)
          areAllPointsInside Determines whether all the points in framePoints are inside the convex polygon.
 FrameConvexPolygon2d changeFrameAndProjectToXYPlaneCopy(ReferenceFrame desiredFrame)
           
 FrameConvexPolygon2d changeFrameCopy(ReferenceFrame desiredFrame)
           
 void checkReferenceFrameMatch(ReferenceFrame frame)
           
 void checkReferenceFrameMatch(ReferenceFrameHolder referenceFrameHolder)
           
static FrameConvexPolygon2dAndConnectingEdges combineDisjointPolygons(FrameConvexPolygon2d polygon1, FrameConvexPolygon2d polygon2)
           
 FrameConvexPolygon2d combineWith(FrameConvexPolygon2d secondPolygon)
          combine Creates new convex polygon.
static FrameConvexPolygon2d constructByProjectionOntoXYPlane(java.util.List<FramePoint> points, ReferenceFrame frame)
           
 double distance(FrameConvexPolygon2d secondConvexPolygon)
           
 double distance(FrameLine2d line)
           
 double distance(FrameLineSegment2d lineSegment)
           
 double distance(FramePoint2d point)
           
 double distanceToClosestVertex(FramePoint2d point)
           
 double[] distanceToEachVertex(FramePoint2d point)
           
 java.util.ArrayList<FramePoint2d> getAllVisibleVerticesFromOutsideLeftToRight(FramePoint2d observerFramePoint)
          Returns all of the vertices that are visible from the observerPoint2d, in left to right order.
 double getArea()
           
 FrameLineSegment2d[] getAroundTheCornerEdges(FramePoint2d observerFramePoint)
          Returns the two FrameLineSegment2ds that are the first segments around the corner that cannot be seen from the observer FramePoint2d.
 BoundingBox2d getBoundingBox()
           
 void getCentroid(FramePoint2d centroid)
           
 FramePoint2d getCentroidCopy()
           
 java.util.ArrayList<FramePoint2d> getClockwiseOrderedListOfFramePoints()
           
 FrameLineSegment2d getClosestEdge(FramePoint2d point)
           
 FramePoint2d getClosestVertexCopy(FrameLine2d line)
           
 FramePoint2d getClosestVertexCopy(FramePoint2d point)
           
 ConvexPolygon2d getConvexPolygon2d()
           
 ConvexPolygon2d getConvexPolygon2dCopy()
           
 FrameLineSegment2d[] getIntersectingEdges(FrameLine2d frameLine2d)
          Returns the intersecting edges between this polygon and the given FrameLine2d.
 FramePoint2d[] getLineOfSightVertices(FramePoint2d observerFramePoint)
           
 FrameLineSegment2d[] getLineSegmentsOfSight(FramePoint2d observerFramePoint)
           
 FrameLine2d[] getLinesOfSight(FramePoint2d observerFramePoint)
           
 FramePoint2d getMeanPointCopy()
           
 FrameLineSegment2d[] getNearestEdges(FramePoint2d testPoint)
           
 int getNumberOfVertices()
           
 ReferenceFrame getReferenceFrame()
           
 FrameConvexPolygon2d intersectionWith(FrameConvexPolygon2d secondConvexPolygon)
           
 FramePoint2d[] intersectionWith(FrameLine2d line)
           
 FramePoint2d[] intersectionWith(FrameLineSegment2d lineSegment)
           
 FramePoint2d[] intersectionWithRay(FrameLine2d ray)
           
 boolean isPointInside(FramePoint2d framePoint)
           
 boolean isPointInside(FramePoint2d framePoint, double epsilon)
          isPointInside Determines whether a point is inside the convex polygon (point in polygon test).
 FramePoint2d maxXMaxYPointCopy()
           
 FramePoint2d maxXMinYPointCopy()
           
 FramePoint2d minXMaxYPointCopy()
           
 FramePoint2d minXMinYPointCopy()
           
 void orthogonalProjection(FramePoint2d point)
           
 FramePoint2d orthogonalProjectionCopy(FramePoint2d point)
           
 double perimeter()
           
 FramePoint2d pointOnPerimeterGivenParameter(double parameter)
           
 void pullPointTowardsCentroid(FramePoint2d point, double percent)
           
 FramePoint2d pullTowardsCentroidCopy(FramePoint2d point, double percent)
           
static FrameConvexPolygon2d shrinkConstantDistanceInto(double distance, FrameConvexPolygon2d polygonQ)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FrameConvexPolygon2d

public FrameConvexPolygon2d(ReferenceFrame referenceFrame,
                            ConvexPolygon2d convexPolygon2d)

FrameConvexPolygon2d

public FrameConvexPolygon2d(ReferenceFrame referenceFrame,
                            java.util.List<javax.vecmath.Point2d> pointList)

FrameConvexPolygon2d

public FrameConvexPolygon2d(ReferenceFrame referenceFrame,
                            double[][] pointList)

FrameConvexPolygon2d

public FrameConvexPolygon2d(java.util.Collection<FramePoint2d> framePointList)

FrameConvexPolygon2d

public FrameConvexPolygon2d(FrameConvexPolygon2d frameConvexPolygon2d)
Method Detail

getConvexPolygon2dCopy

public ConvexPolygon2d getConvexPolygon2dCopy()

getArea

public double getArea()

getCentroid

public void getCentroid(FramePoint2d centroid)

getCentroidCopy

public FramePoint2d getCentroidCopy()

getNumberOfVertices

public int getNumberOfVertices()

getConvexPolygon2d

public ConvexPolygon2d getConvexPolygon2d()

getClockwiseOrderedListOfFramePoints

public java.util.ArrayList<FramePoint2d> getClockwiseOrderedListOfFramePoints()

getBoundingBox

public BoundingBox2d getBoundingBox()

isPointInside

public boolean isPointInside(FramePoint2d framePoint)

isPointInside

public boolean isPointInside(FramePoint2d framePoint,
                             double epsilon)
isPointInside Determines whether a point is inside the convex polygon (point in polygon test). Uses the orientation method (Nordbeck, Rystedt, 1967) Test is only valid for convex polygons, and only if the vertices are ordered clockwise.

Parameters:
framePoint - FramePoint2d the point to be tested
Returns:
boolean true if the point is inside the polygon

areAllPointsInside

public boolean areAllPointsInside(FramePoint2d[] framePoints)
areAllPointsInside Determines whether all the points in framePoints are inside the convex polygon.

Parameters:
framePoints - FramePoint2d[]
Returns:
boolean

getLinesOfSight

public FrameLine2d[] getLinesOfSight(FramePoint2d observerFramePoint)

getAllVisibleVerticesFromOutsideLeftToRight

public java.util.ArrayList<FramePoint2d> getAllVisibleVerticesFromOutsideLeftToRight(FramePoint2d observerFramePoint)
Returns all of the vertices that are visible from the observerPoint2d, in left to right order. If the observerPoint2d is inside the polygon, returns null.

Parameters:
observerFramePoint - Point2d
Returns:
Point2d[]

getLineOfSightVertices

public FramePoint2d[] getLineOfSightVertices(FramePoint2d observerFramePoint)

getAroundTheCornerEdges

public FrameLineSegment2d[] getAroundTheCornerEdges(FramePoint2d observerFramePoint)
Returns the two FrameLineSegment2ds that are the first segments around the corner that cannot be seen from the observer FramePoint2d. If the observer FramePoint2d is null returns null. The line segments are returned in order of left, then right. The line segments go from the line of sight points to the points that are not in view, but are around the corner.

Parameters:
observerFramePoint - FramePoint2d marking the point of observation of this ConvexPolygon2d.
Returns:
FrameLineSegment2d[] Two line segments going from the line of sight points to the first points around the corners that are out of sight. null if the observer FramePoint2d is inside this FrameConvexPolygon2d.

getLineSegmentsOfSight

public FrameLineSegment2d[] getLineSegmentsOfSight(FramePoint2d observerFramePoint)

getIntersectingEdges

public FrameLineSegment2d[] getIntersectingEdges(FrameLine2d frameLine2d)
Returns the intersecting edges between this polygon and the given FrameLine2d. The FrameLine2d is treated as a ray. This method returns null if: - The start point of the ray starts inside the Polygon, - The ray points away from the polygon. - The intersection is a single vertex, - There is no intersection.

Parameters:
frameLine2d - FrameLine2d Ray to check intersection with this Polygon.
Returns:
FrameLineSegment2d[] The two edges that the Ray intersects on this Polygon.

distanceToEachVertex

public double[] distanceToEachVertex(FramePoint2d point)

getClosestVertexCopy

public FramePoint2d getClosestVertexCopy(FramePoint2d point)

getClosestVertexCopy

public FramePoint2d getClosestVertexCopy(FrameLine2d line)

distanceToClosestVertex

public double distanceToClosestVertex(FramePoint2d point)

checkReferenceFrameMatch

public void checkReferenceFrameMatch(ReferenceFrameHolder referenceFrameHolder)
Specified by:
checkReferenceFrameMatch in interface ReferenceFrameHolder

checkReferenceFrameMatch

public void checkReferenceFrameMatch(ReferenceFrame frame)
                              throws ReferenceFrameMismatchException
Specified by:
checkReferenceFrameMatch in interface ReferenceFrameHolder
Throws:
ReferenceFrameMismatchException

getReferenceFrame

public ReferenceFrame getReferenceFrame()
Specified by:
getReferenceFrame in interface ReferenceFrameHolder

changeFrameAndProjectToXYPlaneCopy

public FrameConvexPolygon2d changeFrameAndProjectToXYPlaneCopy(ReferenceFrame desiredFrame)

changeFrameCopy

public FrameConvexPolygon2d changeFrameCopy(ReferenceFrame desiredFrame)
Specified by:
changeFrameCopy in interface ReferenceFrameHolder

applyTransformCopy

public FrameConvexPolygon2d applyTransformCopy(javax.media.j3d.Transform3D transform,
                                               ReferenceFrame newFrame,
                                               boolean requirePlanarTransform)
applyTransformCopy Use of this method is discouraged. Only use it to speed up computation when transforming large FrameConvexPolygon2ds or when transforming them en masse, and only when the desired reference frame is not a parent or child of the current reference frame.

Parameters:
transform - Transform3D
newFrame - ReferenceFrame
requirePlanarTransform - boolean
Returns:
FrameConvexPolygon2d

toString

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

getNearestEdges

public FrameLineSegment2d[] getNearestEdges(FramePoint2d testPoint)

orthogonalProjection

public void orthogonalProjection(FramePoint2d point)
Specified by:
orthogonalProjection in interface FrameGeometry2d

orthogonalProjectionCopy

public FramePoint2d orthogonalProjectionCopy(FramePoint2d point)
Specified by:
orthogonalProjectionCopy in interface FrameGeometry2d

intersectionWith

public FramePoint2d[] intersectionWith(FrameLine2d line)
Specified by:
intersectionWith in interface FrameGeometry2d

intersectionWithRay

public FramePoint2d[] intersectionWithRay(FrameLine2d ray)

intersectionWith

public FramePoint2d[] intersectionWith(FrameLineSegment2d lineSegment)
Specified by:
intersectionWith in interface FrameGeometry2d

intersectionWith

public FrameConvexPolygon2d intersectionWith(FrameConvexPolygon2d secondConvexPolygon)
Specified by:
intersectionWith in interface FrameGeometry2d

distance

public double distance(FramePoint2d point)
Specified by:
distance in interface FrameGeometry2d

getClosestEdge

public FrameLineSegment2d getClosestEdge(FramePoint2d point)

distance

public double distance(FrameLine2d line)
Specified by:
distance in interface FrameGeometry2d

distance

public double distance(FrameLineSegment2d lineSegment)
Specified by:
distance in interface FrameGeometry2d

distance

public double distance(FrameConvexPolygon2d secondConvexPolygon)
Specified by:
distance in interface FrameGeometry2d

minXMaxYPointCopy

public FramePoint2d minXMaxYPointCopy()

minXMinYPointCopy

public FramePoint2d minXMinYPointCopy()

maxXMaxYPointCopy

public FramePoint2d maxXMaxYPointCopy()

maxXMinYPointCopy

public FramePoint2d maxXMinYPointCopy()

perimeter

public double perimeter()

pointOnPerimeterGivenParameter

public FramePoint2d pointOnPerimeterGivenParameter(double parameter)

pullPointTowardsCentroid

public void pullPointTowardsCentroid(FramePoint2d point,
                                     double percent)

pullTowardsCentroidCopy

public FramePoint2d pullTowardsCentroidCopy(FramePoint2d point,
                                            double percent)

shrinkConstantDistanceInto

public static FrameConvexPolygon2d shrinkConstantDistanceInto(double distance,
                                                              FrameConvexPolygon2d polygonQ)

combineWith

public FrameConvexPolygon2d combineWith(FrameConvexPolygon2d secondPolygon)
combine Creates new convex polygon. Its clockwiseOrderedListOfPoints is the convex hull of all the vertices of the polygons it was created from.

Parameters:
secondPolygon - ConvexPolygon2d
Returns:
ConvexPolygon2d

combineDisjointPolygons

public static FrameConvexPolygon2dAndConnectingEdges combineDisjointPolygons(FrameConvexPolygon2d polygon1,
                                                                             FrameConvexPolygon2d polygon2)

getMeanPointCopy

public FramePoint2d getMeanPointCopy()

constructByProjectionOntoXYPlane

public static FrameConvexPolygon2d constructByProjectionOntoXYPlane(java.util.List<FramePoint> points,
                                                                    ReferenceFrame frame)