public WPoint2D IntersectWith(WLine2D other) { if (this.IsParallelTo(other)) { return(null); } WPoint2D p = this.StartPoint; WPoint2D q = other.StartPoint; WVector2D r = this.StartPoint.VectorTo(this.EndPoint); WVector2D s = other.StartPoint.VectorTo(other.EndPoint); double t = (q - p).CrossProduct(s) / (r.CrossProduct(s)); return(p + t * r); }
/// 判断该线是否与另一条线在一定的角度公差范围内平行 /// Checks to determine whether or not two lines are parallel to each other within a specified angle tolerance /// </summary> /// <param name="other">The other line to check this one against</param> /// <param name="angleTolerance">If the angle between line directions is less than this value, the method returns true</param> /// <returns>True if the lines are parallel within the angle tolerance, false if they are not</returns> public bool IsParallelTo(WLine2D other, Angle angleTolerance) { return(this.Direction.IsParallelTo(other.Direction, angleTolerance)); }
/// 判断该线是否与另一条线平行 /// Checks to determine whether or not two lines are parallel to each other, using the dot product within /// the double precision specified in the MathNet.Numerics package. /// </summary> /// <param name="other">The other line to check this one against</param> /// <returns>True if the lines are parallel, false if they are not</returns> public bool IsParallelTo(WLine2D other) { return(this.Direction.IsParallelTo(other.Direction, WGeos2D_Paras.E_Angle)); }