/// <summary> /// Distance to the line. /// </summary> /// <param name="Line">The line to test.</param> public double Distance(C2DLineBase Line) { if (Lines.Count == 0) { return(0); } var pt1 = new C2DPoint(); var pt2 = new C2DPoint(); double dMin = Lines[0].Distance(Line, pt1, pt2); double dDist; for (var i = 1; i < Lines.Count; i++) { dDist = Lines[i].Distance(Line, pt1, pt2); if (dDist == 0) { return(0); } if (dDist < dMin) { dMin = dDist; } } if (Contains(Line.GetPointFrom())) { return(-dMin); } else { return(dMin); } }
/// <summary> /// True if it crosses the line. Provides the intersection points. /// </summary> /// <param name="Line">The other line.</param> /// <param name="IntersectionPts">Output. The intersection points.</param> public bool Crosses(C2DLineBase Line, List <C2DPoint> IntersectionPts) { var LineRect = new C2DRect(); Line.GetBoundingRect(LineRect); if (!BoundingRect.Overlaps(LineRect)) { return(false); } Debug.Assert(Lines.Count == LineRects.Count); if (Lines.Count != LineRects.Count) { return(false); } var IntersectionTemp = new C2DPointSet(); var bResult = false; for (var i = 0; i < this.Lines.Count; i++) { if (LineRects[i].Overlaps(LineRect) && Lines[i].Crosses(Line, IntersectionTemp as List <C2DPoint>)) { bResult = true; } } IntersectionPts.InsertRange(0, IntersectionTemp); return(bResult); }
/// <summary> /// True if it entirely contains the line. /// </summary> /// <param name="Line">The line to test.</param> public bool Contains(C2DLineBase Line) { if (!Contains(Line.GetPointFrom())) { return(false); } var Pts = new C2DPointSet(); return(!Crosses(Line, Pts)); }
/// <summary> /// Transform by a user defined transformation. e.g. a projection. /// </summary> public void InverseTransform(CTransformation pProject) { for (var i = 0; i < this._Lines.Count; i++) { C2DLineBase pLine = _Lines[i]; pLine.InverseTransform(pProject); pLine.GetBoundingRect(_LineRects[i]); } this.MakeBoundingRect(); }
/// <summary> /// True if this crosses the line. /// </summary> /// <param name="Line">Line to test for.</param> /// <param name="IntersectionPts">Point set to recieve the intersections.</param> public bool Crosses(C2DLineBase Line, C2DPointSet IntersectionPts) { var IntPts = new C2DPointSet(); _Rim.Crosses(Line, IntPts); for (var i = 0; i < _Holes.Count; i++) { _Holes[i].Crosses(Line, IntPts); } var bResult = (IntPts.Count != 0); IntersectionPts.ExtractAllOf(IntPts); return(bResult); }
/// <summary> /// True if this crosses the line /// </summary> /// <param name="Line">Line to test for.</param> public bool Crosses(C2DLineBase Line) { if (_Rim.Crosses(Line)) { return(true); } for (var i = 0; i < _Holes.Count; i++) { if (_Holes[i].Crosses(Line)) { return(true); } } return(false); }
/// <summary> /// Returns the minimum distance from the other line to this providing closest points. /// </summary> /// <param name="Other">The test point.</param> /// <param name="ptOnThis">The closest point on this to the other as a returned value.</param> /// <param name="ptOnOther">The closest point on the other to this as a returned value.</param> public override double Distance(C2DLineBase Other, C2DPoint ptOnThis, C2DPoint ptOnOther) { if (Other is C2DLine) { return(Distance(Other as C2DLine, ptOnThis, ptOnOther)); } else if (Other is C2DArc) { return(Distance(Other as C2DArc, ptOnThis, ptOnOther)); } else { Debug.Assert(false, "Invalid line type"); return(0); } }
/// <summary> /// True if this crosses the line given as a base class. /// </summary> /// <param name="Other">The other line as an abstract base class.</param> /// <param name="IntersectionPts">The interection point list to recieve the result.</param> public override bool Crosses(C2DLineBase Other, List <C2DPoint> IntersectionPts) { if (Other is C2DLine) { return(Crosses(Other as C2DLine, IntersectionPts)); } else if (Other is C2DArc) { return(Crosses(Other as C2DArc, IntersectionPts)); } else { Debug.Assert(false, "Invalid line type"); return(false); } }
/// <summary> /// Intersection with a line base. /// </summary> /// <param name="Line">The other line.</param> public bool Crosses(C2DLineBase Line) { var LineRect = new C2DRect(); Line.GetBoundingRect(LineRect); var Temp = new List <C2DPoint>(); for (var i = 0; i < this.Lines.Count; i++) { if (LineRects[i].Overlaps(LineRect) && Lines[i].Crosses(Line, Temp)) { return(true); } } return(false); }
/// <summary> /// Line entirely inside test. /// </summary> /// <param name="Line">Line to test for.</param> public bool Contains(C2DLineBase Line) { if (!_Rim.Contains(Line)) { return(false); } for (var i = 0; i < _Holes.Count; i++) { if (_Holes[i].Crosses(Line) || _Holes[i].Contains(Line.GetPointFrom())) { return(false); } } return(true); }
/// <summary> /// Distance from the line provided. /// </summary> /// <param name="Line">Line to find the distance to.</param> public double Distance(C2DLineBase Line) { var dResult = _Rim.Distance(Line); if (dResult == 0) { return(0); } var bInside = dResult < 0; dResult = Math.Abs(dResult); for (var i = 0; i < _Holes.Count; i++) { var dDist = _Holes[i].Distance(Line); if (dDist == 0) { return(0); } if (dDist < 0) { bInside = false; } if (Math.Abs(dDist) < dResult) { dResult = Math.Abs(dDist); } } if (bInside) { return(dResult); } else { return(-dResult); } }
/// <summary> /// Creates a random shape. /// </summary> /// <param name="cBoundary">The boundary.</param> /// <param name="nMinPoints">The minimum points.</param> /// <param name="nMaxPoints">The maximum points.</param> public bool CreateRandom(C2DRect cBoundary, int nMinPoints, int nMaxPoints) { C2DPolygon Poly = new C2DPolygon(); if (!Poly.CreateRandom(cBoundary, nMinPoints, nMaxPoints)) { return(false); } CRandomNumber rCenOnRight = new CRandomNumber(0, 1); this.Set(Poly); for (int i = 0; i < Lines.Count; i++) { C2DLineBase pLine = Lines[i]; bool bCenOnRight = (rCenOnRight.GetInt() > 0); double dLength = pLine.GetLength(); CRandomNumber Radius = new CRandomNumber(dLength, dLength * 3); C2DArc pNew = new C2DArc(pLine.GetPointFrom(), pLine.GetPointTo(), Radius.Get(), bCenOnRight, !bCenOnRight); if (!this.Crosses(pNew)) { Lines[i] = pNew; pNew.GetBoundingRect(LineRects[i]); BoundingRect.ExpandToInclude(LineRects[i]); } } // this.MakeLineRects(); // this.MakeBoundingRect(); return(true); }
/// <summary> /// True if this crosses the line. /// </summary> /// <param name="Line">Line to test for.</param> /// <param name="IntersectionPts">Point set to recieve the intersections.</param> public bool Crosses(C2DLineBase Line, C2DPointSet IntersectionPts) { C2DPointSet IntPts = new C2DPointSet(); _Rim.Crosses(Line, IntPts); for (int i = 0 ; i < _Holes.Count; i++) { _Holes[i].Crosses(Line, IntPts); } bool bResult = (IntPts.Count != 0); IntersectionPts.ExtractAllOf(IntPts); return (bResult); }
/// <summary> /// True if this crosses the line /// </summary> /// <param name="Line">Line to test for.</param> public bool Crosses(C2DLineBase Line) { if (_Rim.Crosses(Line)) return true; for (int i = 0 ; i < _Holes.Count; i++) { if (_Holes[i].Crosses(Line)) return true; } return false; }
/// <summary> /// Line entirely inside test. /// </summary> /// <param name="Line">Line to test for.</param> public bool Contains(C2DLineBase Line) { if (!_Rim.Contains(Line)) return false; for ( int i = 0 ; i < _Holes.Count; i++) { if (_Holes[i].Crosses(Line) || _Holes[i].Contains( Line.GetPointFrom())) return false; } return true; }
/// <summary> /// Distance from the line provided. /// </summary> /// <param name="Line">Line to find the distance to.</param> public double Distance(C2DLineBase Line) { double dResult = _Rim.Distance(Line); if (dResult == 0) return 0; bool bInside = dResult < 0; dResult = Math.Abs(dResult); for ( int i = 0; i < _Holes.Count; i++) { double dDist = _Holes[i].Distance(Line); if (dDist == 0) return 0; if (dDist < 0) bInside = false; if (Math.Abs(dDist) < dResult) dResult = Math.Abs(dDist); } if (bInside) return dResult; else return - dResult; }
/// <summary> /// True if it crosses the line. Provides the intersection points. /// </summary> /// <param name="Line">The other line.</param> /// <param name="IntersectionPts">Output. The intersection points.</param> public bool Crosses(C2DLineBase Line, List<C2DPoint> IntersectionPts) { C2DRect LineRect = new C2DRect(); Line.GetBoundingRect( LineRect); if (!BoundingRect.Overlaps(LineRect)) return false; Debug.Assert(Lines.Count == LineRects.Count); if(Lines.Count != LineRects.Count) return false; C2DPointSet IntersectionTemp = new C2DPointSet(); bool bResult = false; for (int i = 0; i < this.Lines.Count; i++) { if (LineRects[i].Overlaps(LineRect) && Lines[i].Crosses(Line, IntersectionTemp as List<C2DPoint>)) { bResult = true; } } IntersectionPts.InsertRange(0, IntersectionTemp); return bResult; }
/// <summary> /// Intersection with another /// </summary> public abstract bool Crosses(C2DLineBase Other, List <C2DPoint> IntersectionPts);
/// <summary> /// Distance to the line. /// </summary> /// <param name="Line">The line to test.</param> public double Distance(C2DLineBase Line) { if (Lines.Count == 0) return 0; C2DPoint pt1 = new C2DPoint(); C2DPoint pt2 = new C2DPoint(); double dMin = Lines[0].Distance(Line, pt1, pt2); double dDist; for (int i = 1 ; i < Lines.Count; i++) { dDist = Lines[i].Distance(Line, pt1, pt2); if (dDist == 0 ) return 0; if (dDist < dMin) dMin = dDist; } if ( Contains(Line.GetPointFrom())) return -dMin; else return dMin; }
/// <summary> /// Minimum distance to another. /// </summary> public abstract double Distance(C2DLineBase Other, C2DPoint ptOnThis, C2DPoint ptOnOther);
/// <summary> /// True if this line crosses the other line, returns the intersection pt. /// </summary> /// <param name="Other">The other line to test.</param> /// <param name="IntersectionPts">Output. The intersection points.</param> public override bool Crosses(C2DLineBase Other, List<C2DPoint> IntersectionPts) { if (Other is C2DLine) { return Crosses( Other as C2DLine, IntersectionPts); } else if (Other is C2DArc) { C2DArc Arc = Other as C2DArc; return Arc.Crosses(this, IntersectionPts); } else { Debug.Assert(false, "Invalid Line type"); return false; } }
/// <summary> /// Intersection with a line base. /// </summary> /// <param name="Line">The other line.</param> public bool Crosses(C2DLineBase Line) { C2DRect LineRect = new C2DRect (); Line.GetBoundingRect(LineRect); List<C2DPoint> Temp = new List<C2DPoint>(); for (int i = 0; i < this.Lines.Count; i++) { if (LineRects[i].Overlaps( LineRect ) && Lines[i].Crosses(Line, Temp)) return true; } return false; }
/// <summary> /// True if it entirely contains the line. /// </summary> /// <param name="Line">The line to test.</param> public bool Contains(C2DLineBase Line) { if (!Contains(Line.GetPointFrom())) return false; C2DPointSet Pts = new C2DPointSet(); return !Crosses(Line, Pts); }
/// <summary> /// Returns the distance from this to the other line. /// </summary> /// <param name="Other">The other line.</param> /// <param name="ptOnThis">Output. The closest point on this.</param> /// <param name="ptOnOther">Output. The closest point on the other line.</param> public override double Distance(C2DLineBase Other, C2DPoint ptOnThis , C2DPoint ptOnOther) { if (Other is C2DLine) { return Distance( Other as C2DLine, ptOnThis, ptOnOther); } else if (Other is C2DArc) { C2DArc Arc = Other as C2DArc; return Arc.Distance(this, ptOnThis, ptOnOther); } else { Debug.Assert(false, "Invalid Hole type"); return 0; } }
/// <summary> /// Intersection with another /// </summary> public abstract bool Crosses(C2DLineBase Other, List<C2DPoint> IntersectionPts);