예제 #1
0
		public StrokeSegment (Stroke stroke, int startIndex, int lastIndex)
		{
			_points = stroke.Points;

			if (startIndex >= _points.Length) throw new ArgumentOutOfRangeException ("startIndex");
			if (lastIndex >= _points.Length) throw new ArgumentOutOfRangeException ("lastIndex");

			StartIndex = startIndex;
			EndIndex = lastIndex;
		}
예제 #2
0
		public Stroke GetSimplifiedStroke (int startIndex, float error, int maxSegments)
		{
			var segs = GetSimplifiedSegments (startIndex, error, maxSegments);
			var ss = new Stroke (CreatedTime);

			ss.AddPoint (segs [0].StartPoint);
			foreach (var s in segs) {
				ss.AddPoint (s.EndPoint);
			}

			return ss;
		}
예제 #3
0
		public bool IntersectsWith (LineSegmentF lineSegment)
		{
			var other = new Stroke ();
			other.AddPoint (lineSegment.Start);
			other.AddPoint (lineSegment.End);
			return GetIntersectionWith (other) != null;
		}
예제 #4
0
		public IntersectionInfo GetIntersectionWith (Stroke other)
		{
			for (var i = 0; i < _points.Count - 1; i++) {
				
				var x1 = _points [i].X;
				var y1 = _points [i].Y;
				var x21 = _points [i + 1].X - x1;
				var y21 = _points [i + 1].Y - y1;
				
				for (var j = 0; j < other._points.Count - 1; j++) {
					
					var x3 = other._points [j].X;
					var y3 = other._points [j].Y;
					var x43 = other._points [j + 1].X - x3;
					var y43 = other._points [j + 1].Y - y3;
					var x13 = x1 - x3;
					var y13 = y1 - y3;
					
					var d = y43*x21 - x43*y21;
					if (d == 0.0f) continue;
					
					var na = x43*y13 - y43*x13;
					var ua = na / d;
					
					if (ua < 0 || ua > 1) continue;
					
					var nb = x21*y13 - y21*x13;
					var ub = nb / d;
					
					if (ub >= 0 && ub <= 1) {
						var loc = new PointF (x1 + ua * x21, y1 + ua * y21);
						return new IntersectionInfo (loc);
					}
				}
			}
			
			return null;
		}
예제 #5
0
		public bool IntersectsWith (Stroke other)
		{
			return GetIntersectionWith (other) != null;
		}