public static ArborPoint intersect_line_line(ArborPoint p1, ArborPoint p2, ArborPoint p3, ArborPoint p4) { double denom = ((p4.Y - p3.Y) * (p2.X - p1.X) - (p4.X - p3.X) * (p2.Y - p1.Y)); if (denom == 0) { return(ArborPoint.Null); // lines are parallel } double ua = ((p4.X - p3.X) * (p1.Y - p3.Y) - (p4.Y - p3.Y) * (p1.X - p3.X)) / denom; double ub = ((p2.X - p1.X) * (p1.Y - p3.Y) - (p2.Y - p1.Y) * (p1.X - p3.X)) / denom; if (ua < 0 || ua > 1 || ub < 0 || ub > 1) { return(ArborPoint.Null); } return(new ArborPoint(p1.X + ua * (p2.X - p1.X), p1.Y + ua * (p2.Y - p1.Y))); }
internal void applyForce(ArborPoint a) { this.F = this.F.add(a.div(this.Mass)); }