本文整理汇总了Java中math.geom2d.Point2D.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Point2D.equals方法的具体用法?Java Point2D.equals怎么用?Java Point2D.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类math.geom2d.Point2D
的用法示例。
在下文中一共展示了Point2D.equals方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findNextPoint
import math.geom2d.Point2D; //导入方法依赖的package包/类
private Point2D findNextPoint(Point2D basePoint, double startAngle,
Collection<? extends Point2D> points) {
Point2D minPoint = null;
double minAngle = Double.MAX_VALUE;
double angle;
for (Point2D point : points) {
// Avoid to test same point
if (basePoint.equals(point))
continue;
// Compute angle between current direction and next point
angle = Angle2D.getHorizontalAngle(basePoint, point);
angle = Angle2D.formatAngle(angle-startAngle);
// Keep current point if angle is minimal
if (angle<minAngle) {
minAngle = angle;
minPoint = point;
}
}
return minPoint;
}
示例2: getOtherPoint
import math.geom2d.Point2D; //导入方法依赖的package包/类
/**
* Return the opposite vertex of the edge.
*
* @param point one of the vertices of the edge
* @return the other vertex, or null if point is nor a vertex of the edge
*/
public Point2D getOtherPoint(Point2D point) {
if (point.equals(new Point2D(x0, y0)))
return new Point2D(x0+dx, y0+dy);
if (point.equals(new Point2D(x0+dx, y0+dy)))
return new Point2D(x0, y0);
return null;
}
示例3: getOtherPoint
import math.geom2d.Point2D; //导入方法依赖的package包/类
/**
* Return the opposite vertex of the edge.
*
* @param point : one of the vertices of the edge
* @return the other vertex
*/
public Point2D getOtherPoint(Point2D point) {
if (point.equals(p1))
return p2;
if (point.equals(p2))
return p1;
return null;
}
示例4: findSelfIntersections
import math.geom2d.Point2D; //导入方法依赖的package包/类
/**
* Compute intersection point of a single curve, by iterating on pair of
* Circulinear elements composing the curve.
* @return the set of self-intersection points
*/
public static Collection<Point2D> findSelfIntersections(
CirculinearCurve2D curve) {
// create array of circulinear elements
ArrayList<CirculinearElement2D> elements =
new ArrayList<CirculinearElement2D>();
// extract all circulinear elements of the curve
for(CirculinearContinuousCurve2D cont : curve.getContinuousCurves())
elements.addAll(cont.getSmoothPieces());
// create array for storing result
ArrayList<Point2D> result = new ArrayList<Point2D>(0);
// iterate on each couple of elements
int n = elements.size();
for(int i=0; i<n-1; i++) {
CirculinearElement2D elem1 = elements.get(i);
for(int j=i; j<n; j++) {
CirculinearElement2D elem2 = elements.get(j);
// iterate on intersection between consecutive elements
for(Point2D inter : findIntersections(elem1, elem2)) {
// do not keep extremities
if(inter.equals(elem1.getLastPoint()) &&
inter.equals(elem2.getFirstPoint())) continue;
if(inter.equals(elem1.getFirstPoint()) &&
inter.equals(elem2.getLastPoint())) continue;
// add the intersection if we keep it
result.add(inter);
}
}
}
// return the set of intersections
return result;
}
示例5: equals
import math.geom2d.Point2D; //导入方法依赖的package包/类
/**
* Test if rectangles are the same. We consider two rectangles are equal if
* their corners are the same. Then, we can have different origins and
* different angles, but equal rectangles.
*/
@Override
public boolean equals(Object obj) {
// check class, and cast type
if (!(obj instanceof HRectangle2D))
return false;
HRectangle2D rect = (HRectangle2D) obj;
// check all 4 corners of the first rectangle
boolean ok;
for (Point2D point : this.getVertices()) {
ok = false;
// compare with all 4 corners of second rectangle
for (Point2D point2 : rect.getVertices())
if (point.equals(point2))
ok = true;
// if the point does not belong to the corners of the other
// rectangle,
// then the two rectangles are different
if (!ok)
return false;
}
// test ok for 4 corners, then the two rectangles are the same.
return true;
}
示例6: equals
import math.geom2d.Point2D; //导入方法依赖的package包/类
/**
* Test if retangles are the same. We consider two rectangles are equals if
* their corners are the same. Then, we can have different origin and
* different angles, but equal rectangles.
*/
@Override
public boolean equals(Object obj) {
// check class, and cast type
if (!(obj instanceof Rectangle2D))
return false;
Rectangle2D rect = (Rectangle2D) obj;
// first get list of corners of the 2 rectangles.
// Iterator<Point2D> iter1 = this.getPoints();
// Point2D point;
// check all 4 corners of the first rectangle
// while(iter1.hasNext()){
// point = (Point2D) iter1.next();
boolean ok;
for (Point2D point : this.getVertices()) {
ok = false;
// compare with all 4 corners of second rectangle
// Iterator<Point2D> iter2 = rect.getPoints();
// while(iter2.hasNext())
// if(point.equals(iter2.next()))
// ok = true;
for (Point2D point2 : rect.getVertices())
if (point.equals(point2)) {
ok = true;
break;
}
// if the point does not belong to the corners of the other
// rectangle,
// then the two rect are different
if (!ok)
return false;
}
// test ok for 4 corners, then the two rectangles are the same.
return true;
}
示例7: locateSelfIntersections
import math.geom2d.Point2D; //导入方法依赖的package包/类
public static double [][] locateSelfIntersections(
CurveSet2D<? extends CirculinearElement2D> curve) {
// create array for storing result
ArrayList<Double> list1 = new ArrayList<Double>(0);
ArrayList<Double> list2 = new ArrayList<Double>(0);
// iterate on each couple of elements
int n = curve.getCurveNumber();
for(int i=0; i<n-1; i++) {
CirculinearElement2D elem1 = curve.getCurve(i);
for(int j=i+1; j<n; j++) {
CirculinearElement2D elem2 = curve.getCurve(j);
// iterate on intersection between consecutive elements
for(Point2D inter : findIntersections(elem1, elem2)) {
// do not keep extremities
if(!Double.isInfinite(elem1.getT1())&&!Double.isInfinite(elem2.getT0()))
if(inter.equals(elem1.getLastPoint()) &&
inter.equals(elem2.getFirstPoint())) continue;
if(!Double.isInfinite(elem1.getT0())&&!Double.isInfinite(elem2.getT1()))
if(inter.equals(elem1.getFirstPoint()) &&
inter.equals(elem2.getLastPoint())) continue;
// add the intersection if we keep it
list1.add(2*i + Curve2DUtils.toUnitSegment(
elem1.getPosition(inter),
elem1.getT0(), elem1.getT1()));
list2.add(2*j + Curve2DUtils.toUnitSegment(
elem2.getPosition(inter),
elem2.getT0(), elem2.getT1()));
}
}
}
// convert the 2 lists into a n*2 array
int np = list1.size();
double[][] result = new double[np][2];
for(int i=0; i<np; i++){
result[i][0] = list1.get(i);
result[i][1] = list2.get(i);
}
// return the array of positions
return result;
}