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


Java Line2D类代码示例

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


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

示例1:

import math.geom2d.line.Line2D; //导入依赖的package包/类
/**
	 * Returns the distance and the closest segment of a point (x,y) to a polygon given as a series of points
	 * @param isClosedShape True if this is a closes polygon or false if its a polyline
	 */
	public static Pair<Double, java.awt.geom.Line2D.Double> 
		getDistToPolygonAndClosestSegment(List<Point> pts, double x, double y, boolean isClosedShape) {
		double minDist = Integer.MAX_VALUE;
		java.awt.geom.Line2D.Double minLine = new java.awt.geom.Line2D.Double(0, 0, 0, 0);
		
		int N = isClosedShape ? pts.size() : pts.size()-1;
		
		for (int i=0; i<N; ++i) {
			java.awt.geom.Line2D.Double line = new java.awt.geom.Line2D.Double(pts.get(i), pts.get( (i+1) % pts.size() ));
			double d = line.ptSegDistSq(x, y);
//			logger.debug("d = "+d);
			if (d < minDist) {
				minDist = d;
				minLine = line;
			}
		}

		return Pair.of(minDist, minLine);
	}
 
开发者ID:Transkribus,项目名称:TranskribusCore,代码行数:24,代码来源:GeomUtils.java

示例2: getBoundingBox

import math.geom2d.line.Line2D; //导入依赖的package包/类
public math.geom2d.Box2D getBoundingBox(LinkedList<CirculinearElement2D> c_el) {
    
    c_el.add(new Line2D(c_el.getLast().lastPoint(), c_el.getFirst().firstPoint()));
    math.geom2d.Box2D bb = null;

    for (int i = 0; i < c_el.size(); i++) {
        CirculinearElement2D el = c_el.get(i);
        math.geom2d.Box2D bb1 = el.boundingBox();
        if (i == 0) {
            bb = bb1;

        } else {
            bb = bb.union(bb1);
        }

    }
    return bb;

}
 
开发者ID:bertlr,项目名称:GCodeViewer,代码行数:20,代码来源:Toolpath.java

示例3: createCircleArc

import math.geom2d.line.Line2D; //导入依赖的package包/类
/**
 * The Arc
 *
 * @param begin
 * @param end
 * @param r
 * @param ccw
 * @return
 */
public CircleArc2D createCircleArc(Point2D begin, Point2D end, double r, boolean ccw) {
        Point2D center = getArcCenterPoint(begin, end, r, ccw);

        double angleBegin = new Line2D(center, begin).horizontalAngle();
        double angleEnd = new Line2D(center, end).horizontalAngle();
        double angleBegin_0 = angleBegin - angleBegin;  // =0
        double angleEnd_0 = angleEnd - angleBegin;

        double extent = 0;
        angleBegin_0 = angleBegin - angleBegin;  // =0
        angleEnd_0 = angleEnd - angleBegin;

        extent = angleEnd_0;

        if (ccw) {
                if (extent < 0) {
                        extent = 2 * Math.PI + extent;
                }
        } else {
                if (extent > 0) {
                        extent = extent - 2 * Math.PI;
                }
        }

        if (Math.abs(extent) > 2 * Math.PI) {
                if (extent > 2 * Math.PI) {
                        extent -= 2 * Math.PI;
                } else if (extent < 2 * Math.PI) {
                        extent += 2 * Math.PI;
                }
        }

        //extent = angleEnd - angleBegin;
        CircleArc2D b = new CircleArc2D(center, r, angleBegin, extent);
        return b;

}
 
开发者ID:bertlr,项目名称:GCodeViewer,代码行数:47,代码来源:geometry.java

示例4: intersection

import math.geom2d.line.Line2D; //导入依赖的package包/类
public static Point intersection(Line2D l1, Line2D l2) {
	return GeomUtils.intersection((int)l1.getX1(), (int)l1.getY1(), (int)l1.getX2(), (int)l1.getY2(),
			(int)l2.getX1(), (int)l2.getY1(), (int)l2.getX2(), (int)l2.getY2());
}
 
开发者ID:Transkribus,项目名称:TranskribusCore,代码行数:5,代码来源:GeomUtils.java


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