本文整理汇总了Java中geometry.planar.FloatPoint.distance_square方法的典型用法代码示例。如果您正苦于以下问题:Java FloatPoint.distance_square方法的具体用法?Java FloatPoint.distance_square怎么用?Java FloatPoint.distance_square使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类geometry.planar.FloatPoint
的用法示例。
在下文中一共展示了FloatPoint.distance_square方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: nearest_trace_exit_corner
import geometry.planar.FloatPoint; //导入方法依赖的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;
}
示例2: calc_airline
import geometry.planar.FloatPoint; //导入方法依赖的package包/类
private void calc_airline(Collection<Item> p_from_items, Collection<Item> p_to_items)
{
FloatPoint from_corner = null;
FloatPoint to_corner = null;
double min_distance = Double.MAX_VALUE;
for (Item curr_from_item : p_from_items)
{
if (!(curr_from_item instanceof DrillItem))
{
continue;
}
FloatPoint curr_from_corner = ((DrillItem) curr_from_item).get_center().to_float();
for (Item curr_to_item : p_to_items)
{
if (!(curr_to_item instanceof DrillItem))
{
continue;
}
FloatPoint curr_to_corner = ((DrillItem) curr_to_item).get_center().to_float();
double curr_distance = curr_from_corner.distance_square(curr_to_corner);
if (curr_distance < min_distance)
{
min_distance = curr_distance;
from_corner = curr_from_corner;
to_corner = curr_to_corner;
}
}
}
this.air_line = new FloatLine(from_corner, to_corner);
}
示例3: SwapPinInfo
import geometry.planar.FloatPoint; //导入方法依赖的package包/类
SwapPinInfo(board.Pin p_pin)
{
pin = p_pin;
incomplete = null;
if (p_pin.is_connected() || p_pin.net_count() != 1)
{
return;
}
// calculate the incomplete of p_pin
FloatPoint pin_center = p_pin.get_center().to_float();
double min_dist = Double.MAX_VALUE;
FloatPoint nearest_point = null;
Collection<Item> net_items = board.get_connectable_items(p_pin.get_net_no(0));
for (Item curr_item : net_items)
{
if (curr_item == this.pin || !(curr_item instanceof DrillItem))
{
continue;
}
FloatPoint curr_point = ((DrillItem) curr_item).get_center().to_float();
double curr_dist = pin_center.distance_square(curr_point);
if (curr_dist < min_dist)
{
min_dist = curr_dist;
nearest_point = curr_point;
}
}
if (nearest_point != null)
{
incomplete = new geometry.planar.FloatLine(pin_center, nearest_point);
}
}
示例4: Edge
import geometry.planar.FloatPoint; //导入方法依赖的package包/类
private Edge(NetItem p_from_item, FloatPoint p_from_corner, NetItem p_to_item, FloatPoint p_to_corner)
{
from_item = p_from_item;
from_corner = p_from_corner;
to_item = p_to_item;
to_corner = p_to_corner;
length_square = p_to_corner.distance_square(p_from_corner);
}
示例5: shove_vias
import geometry.planar.FloatPoint; //导入方法依赖的package包/类
/**
* Shoves vias out of p_obstacle_shape. Returns false, if the database is damaged, so that an undo is necessary afterwards.
*/
static boolean shove_vias(TileShape p_obstacle_shape, CalcFromSide p_from_side, int p_layer, int[] p_net_no_arr,
int p_cl_type, Collection<Item> p_ignore_items, int p_max_recursion_depth,
int p_max_via_recursion_depth, boolean p_copper_sharing_allowed,
RoutingBoard p_board)
{
ShapeSearchTree search_tree = p_board.search_tree_manager.get_default_tree();
ShapeTraceEntries shape_entries =
new ShapeTraceEntries(p_obstacle_shape, p_layer, p_net_no_arr, p_cl_type, p_from_side, p_board);
Collection<Item> obstacles =
search_tree.overlapping_items_with_clearance(p_obstacle_shape, p_layer, new int[0], p_cl_type);
if (!shape_entries.store_items(obstacles, false, p_copper_sharing_allowed))
{
return true;
}
if (p_ignore_items != null)
{
shape_entries.shove_via_list.removeAll(p_ignore_items);
}
if (shape_entries.shove_via_list.isEmpty())
{
return true;
}
double shape_radius = 0.5 * p_obstacle_shape.bounding_box().min_width();
for (Via curr_via : shape_entries.shove_via_list)
{
if (curr_via.shares_net_no(p_net_no_arr))
{
continue;
}
if (p_max_via_recursion_depth <= 0)
{
return true;
}
IntPoint [] try_via_centers =
try_shove_via_points(p_obstacle_shape, p_layer, curr_via, p_cl_type, true, p_board);
IntPoint new_via_center = null;
double max_dist = 0.5 * curr_via.get_shape_on_layer(p_layer).bounding_box().max_width() + shape_radius;
double max_dist_square = max_dist * max_dist;
IntPoint curr_via_center = (IntPoint) curr_via.get_center();
FloatPoint check_via_center = curr_via_center.to_float();
Vector rel_coor = null;
for (int i = 0; i < try_via_centers.length; ++i)
{
if (i == 0 || check_via_center.distance_square(try_via_centers[i].to_float()) <= max_dist_square)
{
Collection<Item> ignore_items = new java.util.LinkedList<Item>();
if (p_ignore_items != null)
{
ignore_items.addAll(p_ignore_items);
}
rel_coor = try_via_centers[i].difference_by(curr_via_center);
// No time limit here because the item database is already changed.
boolean shove_ok = check(curr_via, rel_coor, p_max_recursion_depth,
p_max_via_recursion_depth - 1, ignore_items, p_board, null);
if (shove_ok)
{
new_via_center = try_via_centers[i];
break;
}
}
}
if (new_via_center == null)
{
continue;
}
if (!insert(curr_via, rel_coor, p_max_recursion_depth, p_max_via_recursion_depth - 1, null, p_board))
{
return false;
}
}
return true;
}
示例6: calc_nearest_exit_restriction_direction
import geometry.planar.FloatPoint; //导入方法依赖的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;
}
示例7: enter_through_small_door
import geometry.planar.FloatPoint; //导入方法依赖的package包/类
/**
* Checks, if the next room can be entered if the door of p_list_element is small.
* If p_ignore_item != null, p_ignore_item and all other items directly connected to p_ignore_item
* are ignored in the check.
*/
private boolean enter_through_small_door(MazeListElement p_list_element, Item p_ignore_item)
{
if (p_list_element.door.get_dimension() != 1)
{
return false;
}
TileShape door_shape = p_list_element.door.get_shape();
// Get the line of the 1 dimensional door.
Line door_line = null;
FloatPoint prev_corner = door_shape.corner_approx(0);
int corner_count = door_shape.border_line_count();
for (int i = 1; i < corner_count; ++i)
{
// skip lines of lenghth 0
FloatPoint next_corner = door_shape.corner_approx(i);
if (next_corner.distance_square(prev_corner) > 1)
{
door_line = door_shape.border_line(i - 1);
break;
}
prev_corner = next_corner;
}
if (door_line == null)
{
return false;
}
IntPoint door_center = door_shape.centre_of_gravity().round();
int curr_layer = p_list_element.next_room.get_layer();
int check_radius =
this.ctrl.compensated_trace_half_width[curr_layer] + AutorouteEngine.TRACE_WIDTH_TOLERANCE;
// create a perpendicular line segment of length 2 * check_radius through the door center
Line[] line_arr = new Line[3];
line_arr[0] = door_line.translate(check_radius);
line_arr[1] = new Line(door_center, door_line.direction().turn_45_degree(2));
line_arr[2] = door_line.translate(-check_radius);
Polyline check_polyline = new Polyline(line_arr);
TileShape check_shape = check_polyline.offset_shape(check_radius, 0);
int[] ignore_net_nos = new int[1];
ignore_net_nos[0] = this.ctrl.net_no;
Set<SearchTreeObject> overlapping_objects = new TreeSet<SearchTreeObject>();
this.autoroute_engine.autoroute_search_tree.overlapping_objects(check_shape, curr_layer,
ignore_net_nos, overlapping_objects);
for (SearchTreeObject curr_object : overlapping_objects)
{
if (!(curr_object instanceof Item) || curr_object == p_ignore_item)
{
continue;
}
Item curr_item = (Item) curr_object;
if (!curr_item.shares_net(p_ignore_item))
{
return false;
}
Set<Item> curr_contacts = curr_item.get_normal_contacts();
if (!curr_contacts.contains(p_ignore_item))
{
return false;
}
}
return true;
}