1 import java.util.ArrayList;
11 private ArrayList<Node> subNodes;
12 private ArrayList<Node> tempSubNodes;
14 private Node startNode;
22 if(startNode.
getX() <= endNode.
getX()){
23 this.startNode = startNode;
24 this.endNode = endNode;
26 this.endNode = startNode;
27 this.startNode = endNode;
44 this.endNode = endNode;
60 this.startNode = startNode;
84 tempSubNodes = subNodes;
93 return (node.equals(startNode) || node.equals(endNode));
101 return endNode.
getX()-startNode.
getX();
109 return endNode.
getY()-startNode.
getY();
126 return Math.sqrt(
dx()*
dx()+
dy()*
dy());
140 Node im =
new Edge(is, ie).midPoint();
141 if(is == null || im == null || ie == null)
143 return Math.max(0, 1-(2*
midPoint().distance(im))/is.distance(ie));
151 int[] subX =
new int[subNodes.size()];
152 for(
int i=0; i < subNodes.size(); i++){
153 subX[i] = subNodes.get(i).getXInt();
163 int[] subY =
new int[subNodes.size()];
164 for(
int i=0; i < subNodes.size(); i++){
165 subY[i] = subNodes.get(i).getYInt();
175 double x = (startNode.
getX()+endNode.
getX())/2;
176 double y = (startNode.
getY()+endNode.
getY())/2;
177 return new Node(x,y);
191 subNodes = tempSubNodes;
199 if (subNodes == null){
200 subNodes =
new ArrayList<Node>();
201 subNodes.add(startNode);
203 subNodes.add(endNode);
205 ArrayList<Node> tempList =
new ArrayList<Node>();
206 for(
int i=0; i < subNodes.size()-1; i++){
207 tempList.add(subNodes.get(i));
208 tempList.add(
new Node((subNodes.get(i).getX()+subNodes.get(i+1).getX())/2,
209 (subNodes.get(i).getY()+subNodes.get(i+1).getY())/2));
211 tempList.add(endNode);
222 double angle = Math.cos(Math.acos(Math.abs((
dx()*other.
dx()+
dy()*other.
dy())
235 double pos = lavg/(lavg+bridge.
magnitude());
267 double x1 = startNode.
getX();
268 double y1 = startNode.
getY();
269 double x2 = endNode.
getX();
270 double y2 = endNode.
getY();
276 if((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4) == 0)
278 double px = ((x1*y2-y1*x2)*(x3-x4)-(x1-x2)*(x3*y4-y3*x4))/((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4));
279 double py = ((x1*y2-y1*x2)*(y3-y4)-(y1-y2)*(x3*y4-y3*x4))/((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4));
280 return new Node(px, py);