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


Java Line.intersection_approx方法代码示例

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


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

示例1: nearest_trace_exit_corner

import geometry.planar.Line; //导入方法依赖的package包/类
/**
 * Calculates the nearest trace exit point of the pin on p_layer.
 * Returns null, if the pin has no trace exit restrictions.
 */
public FloatPoint nearest_trace_exit_corner(FloatPoint p_from_point, int  p_trace_half_width, int p_layer)
{
     java.util.Collection<Pin.TraceExitRestriction> trace_exit_restrictions = this.get_trace_exit_restrictions(p_layer);
     if (trace_exit_restrictions.isEmpty())
     {
         return null;
     }
     Shape pin_shape = this.get_shape(p_layer - this.first_layer());
     Point pin_center = this.get_center();
     if (!(pin_shape instanceof TileShape))
     {
         return null;
     }
     final double edge_to_turn_dist = this.board.rules.get_pin_edge_to_turn_dist();
     if (edge_to_turn_dist < 0)
     {
         return null;
     }
     TileShape offset_pin_shape = (TileShape)((TileShape)pin_shape).offset(edge_to_turn_dist + p_trace_half_width);

     // calculate the nearest legal pin exit point to trace_entry_location_approx
     double min_exit_corner_distance = Double.MAX_VALUE;
     FloatPoint nearest_exit_corner = null;
     for (Pin.TraceExitRestriction curr_exit_restriction : trace_exit_restrictions)
     {
         int curr_intersecting_border_line_no = offset_pin_shape.intersecting_border_line_no(pin_center, curr_exit_restriction.direction);
         Line curr_pin_exit_ray = new Line(pin_center, curr_exit_restriction.direction);
         FloatPoint curr_exit_corner = curr_pin_exit_ray.intersection_approx(offset_pin_shape.border_line(curr_intersecting_border_line_no));
         double curr_exit_corner_distance = curr_exit_corner.distance_square(p_from_point);
         if (curr_exit_corner_distance  < min_exit_corner_distance)
         {
             min_exit_corner_distance = curr_exit_corner_distance;
             nearest_exit_corner = curr_exit_corner;
         }
     }
     return nearest_exit_corner;
}
 
开发者ID:andrasfuchs,项目名称:BioBalanceDetector,代码行数:42,代码来源:Pin.java

示例2: calc_nearest_exit_restriction_direction

import geometry.planar.Line; //导入方法依赖的package包/类
/**
 * Calculates the nearest exit restriction direction for changing p_trace_polyline.
 * p_trace_polyline is assumed to start at the pin center.
 * Returns null, if there is no matching exit restrictions.
 */
Direction calc_nearest_exit_restriction_direction(Polyline p_trace_polyline, int  p_trace_half_width, int p_layer)
{
    java.util.Collection<Pin.TraceExitRestriction> trace_exit_restrictions = this.get_trace_exit_restrictions(p_layer);
    if (trace_exit_restrictions.isEmpty())
    {
        return null;
    }
    Shape pin_shape = this.get_shape(p_layer - this.first_layer());
    Point pin_center = this.get_center();
    if (!(pin_shape instanceof TileShape))
    {
        return null;
    }
    final double edge_to_turn_dist = this.board.rules.get_pin_edge_to_turn_dist();
    if (edge_to_turn_dist < 0)
    {
        return null;
    }
    TileShape offset_pin_shape = (TileShape)((TileShape)pin_shape).offset(edge_to_turn_dist + p_trace_half_width);
    int [][] entries = offset_pin_shape.entrance_points(p_trace_polyline);
    if (entries.length == 0)
    {
        return null;
    }
    int [] latest_entry_tuple = entries[entries.length - 1];
    FloatPoint trace_entry_location_approx =
            p_trace_polyline.arr[latest_entry_tuple[0]].intersection_approx(offset_pin_shape.border_line(latest_entry_tuple[1]));
    // calculate the nearest legal pin exit point to trace_entry_location_approx
    double min_exit_corner_distance = Double.MAX_VALUE;
    FloatPoint nearest_exit_corner = null;
    Direction pin_exit_direction = null;
    final double TOLERANCE = 1;
    for (Pin.TraceExitRestriction curr_exit_restriction : trace_exit_restrictions)
    {
        int curr_intersecting_border_line_no = offset_pin_shape.intersecting_border_line_no(pin_center, curr_exit_restriction.direction);
        Line curr_pin_exit_ray = new Line(pin_center, curr_exit_restriction.direction);
        FloatPoint curr_exit_corner = curr_pin_exit_ray.intersection_approx(offset_pin_shape.border_line(curr_intersecting_border_line_no));
        double curr_exit_corner_distance = curr_exit_corner.distance_square(trace_entry_location_approx);
        boolean new_nearest_corner_found = false;
        if (curr_exit_corner_distance + TOLERANCE < min_exit_corner_distance)
        {
            new_nearest_corner_found = true;
        }
        else if (curr_exit_corner_distance < min_exit_corner_distance + TOLERANCE)
        {
            // the distances are near equal, compare to the previous corners of p_trace_polyline
            for (int i = 1; i < p_trace_polyline.corner_count(); ++i )
            {
                FloatPoint curr_trace_corner = p_trace_polyline.corner_approx(i);
                double curr_trace_corner_distance = curr_trace_corner.distance_square(curr_exit_corner);
                double old_trace_corner_distance = curr_trace_corner.distance_square(nearest_exit_corner);
                if (curr_trace_corner_distance + TOLERANCE < old_trace_corner_distance)
                {
                    new_nearest_corner_found = true;
                    break;
                }
                else if (curr_trace_corner_distance > old_trace_corner_distance + TOLERANCE)
                {
                    break;
                }
            }
        }
        if (new_nearest_corner_found)
        {
            min_exit_corner_distance = curr_exit_corner_distance;
            pin_exit_direction = curr_exit_restriction.direction;
            nearest_exit_corner = curr_exit_corner;
        }
    }
    return pin_exit_direction;
}
 
开发者ID:andrasfuchs,项目名称:BioBalanceDetector,代码行数:77,代码来源:Pin.java

示例3: CalcFromSide

import geometry.planar.Line; //导入方法依赖的package包/类
/**
 * calculates the number of the edge line of p_shape  where p_polyline
 * enters. Used in the push trace algorithm to determine the shove direction.
 * p_no is expected between 1 and p_polyline.line_count - 2 inclusive.
 */
CalcFromSide(Polyline p_polyline, int p_no, TileShape p_shape )
{
    int fromside_no = -1;
    FloatPoint intersection = null;
    boolean border_intersection_found = false;
    // calculate the edge_no of p_shape, where p_polyline enters
    for (int curr_no = p_no; curr_no > 0; --curr_no)
    {
        LineSegment curr_seg = new LineSegment(p_polyline, curr_no);
        int [] intersections = curr_seg.border_intersections(p_shape);
        if (intersections.length > 0)
        {
            fromside_no = intersections[0];
            intersection = curr_seg.get_line().intersection_approx(p_shape.border_line(fromside_no));
            border_intersection_found = true;
            break;
        }
    }
    if (!border_intersection_found)
    {
        // The first corner of p_polyline is inside p_shape.
        // Calculate the nearest intersection point of p_polyline.arr[1]
        // with the border of p_shape to the first corner of p_polyline
        FloatPoint from_point = p_polyline.corner_approx(0);
        Line check_line = p_polyline.arr[1];
        double min_dist = Double.MAX_VALUE;
        int edge_count = p_shape.border_line_count();
        for (int i = 0; i < edge_count; ++i)
        {
            Line curr_line = p_shape.border_line(i);
            FloatPoint curr_intersection = check_line.intersection_approx(curr_line);
            double curr_dist =
                    Math.abs(curr_intersection.distance(from_point));
            if (curr_dist < min_dist)
            {
                fromside_no = i;
                intersection = curr_intersection;
                min_dist = curr_dist;
            }
        }
    }
    this.no = fromside_no;
    this.border_intersection = intersection;
}
 
开发者ID:andrasfuchs,项目名称:BioBalanceDetector,代码行数:50,代码来源:CalcFromSide.java


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