当前位置: 首页>>代码示例>>Java>>正文


Java Point2D.distance方法代码示例

本文整理汇总了Java中math.geom2d.Point2D.distance方法的典型用法代码示例。如果您正苦于以下问题:Java Point2D.distance方法的具体用法?Java Point2D.distance怎么用?Java Point2D.distance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在math.geom2d.Point2D的用法示例。


在下文中一共展示了Point2D.distance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDistance

import math.geom2d.Point2D; //导入方法依赖的package包/类
/**
 * Gets the distance of the StraightObject2d to the given point. This method
 * is not designed to be used directly, because AbstractLine2D is an
 * abstract class, but it can be used by subclasses to help computations.
 * 
 * @param x x-coordinate of the point
 * @param y y-coordinate of the point
 * @return distance between this object and the point (x,y)
 */
public double getDistance(double x, double y) {
	// first project on the line
    Point2D proj = getProjectedPoint(x, y);
    
    // if the line contains the projection, returns the distance
    if (contains(proj))
        return proj.distance(x, y);
    
    // otherwise, returns the distance to the closest singular point
    double dist = Double.POSITIVE_INFINITY;
    if(!Double.isInfinite(getT0()))
    	dist = getFirstPoint().getDistance(x, y);
    if(!Double.isInfinite(getT1()))
    	dist = Math.min(dist, getLastPoint().getDistance(x, y));
   	return dist;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:26,代码来源:AbstractLine2D.java

示例2: getDistance

import math.geom2d.Point2D; //导入方法依赖的package包/类
/**
 * Get the distance of the point (x, y) to this edge.
 */
@Override
public double getDistance(double x, double y) {
    Point2D proj = super.getProjectedPoint(x, y);
    if (contains(proj))
        return proj.distance(x, y);
    double d1 = JavaGeomMath.hypot(x0-x, y0-y);
    double d2 = JavaGeomMath.hypot(x0+dx-x, y0+dy-y);
    return Math.min(d1, d2);
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:13,代码来源:LineSegment2D.java

示例3: getDistance

import math.geom2d.Point2D; //导入方法依赖的package包/类
/**
 * Get the distance of the point (x, y) to this edge.
 */
public double getDistance(double x, double y) {
    StraightLine2D support = new StraightLine2D(p1, p2);
    Point2D proj = support.getProjectedPoint(x, y);
    if (contains(proj))
        return proj.distance(x, y);
    double d1 = JavaGeomMath.hypot(p1.getX()-x, p1.getY()-y);
    double d2 = JavaGeomMath.hypot(p2.getX()-x, p2.getY()-y);
    // System.out.println("dist lineObject2D : " + Math.min(d1, d2));
    return Math.min(d1, d2);
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:14,代码来源:Line2D.java

示例4: getDistance

import math.geom2d.Point2D; //导入方法依赖的package包/类
/**
 * Returns the distance of the point (x, y) to this straight line.
 */
@Override
public double getDistance(double x, double y) {
    Point2D proj = super.getProjectedPoint(x, y);
    return proj.distance(x, y);
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:9,代码来源:StraightLine2D.java


注:本文中的math.geom2d.Point2D.distance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。