public bool Intersects(Strand other, out Vector3 intersectPt) { Vector3 pt = Vector3.zero; intersectPt = pt; float m1, m2, c1, c2, x = 0, y = 0; m1 = this.m; c1 = this.c; m2 = other.getLineM(); c2 = other.getLineC(); if (double.IsInfinity(m1)) { //vertical line x = c x = c1; y = (m2 * x) + c2; } else if (double.IsInfinity(m2)) { x = c2; y = (m1 * x) + c1; } else if (m1 != m2) { x = (float)System.Math.Round((c1 - c2) / (m2 - m1), 3); y = (float)System.Math.Round(((m2 * c1) - (m1 * c2)) / (m2 - m1), 3); } if (this.ContainsPoint(x, y) && other.ContainsPoint(x, y)) { // Debug.Log(string.Format("{0} contains ({1},{2})", other.PositionString(), x, y)); intersectPt = new Vector3(x, y, 0); return(true); } return(false); }