public bool Contains(InkRecognitionUnit other) { if (this.BoundingRect == null || other.BoundingRect == null) { return(false); } //var rect = new Rect(this.BoundingRect.TopX, this.BoundingRect.TopY, this.BoundingRect.Width, this.BoundingRect.Height); //var p1 = new Point(other.BoundingRect.TopX, other.BoundingRect.TopY); //var p2 = new Point(other.BoundingRect.TopX + other.BoundingRect.Width, other.BoundingRect.TopY); //var p3 = new Point(other.BoundingRect.TopX + other.BoundingRect.Width, other.BoundingRect.TopY + other.BoundingRect.Height); //var p4 = new Point(other.BoundingRect.TopX, other.BoundingRect.TopY + other.BoundingRect.Height); //var res = 0; //var pList = new List<Point>() //{ // p1,p2,p3,p4 //}; //pList.ForEach(item => //{ // if (rect.Contains(item)) // { // res += 1; // } //}); //return res >= 3; return(this.BoundingRect.OverlapSize(other.BoundingRect) / (other.BoundingRect.Width * other.BoundingRect.Height) > 0.5); }
public float DistanceToRight(InkRecognitionUnit other) { var x1 = this.BoundingRect.TopX + this.BoundingRect.Width; var y1 = this.BoundingRect.TopY + this.BoundingRect.Height / 2; var x2 = other.BoundingRect.TopX; var y2 = other.BoundingRect.TopY; return((float)Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2))); }
public bool IsRightLowerLinked(InkRecognitionUnit other) { if (Math.Abs(this.BoundingRect.TopY + this.BoundingRect.Height - other.BoundingRect.TopY) < Tolerance) { if (Math.Abs(this.BoundingRect.TopX + this.BoundingRect.Width - (other.BoundingRect.TopX + other.BoundingRect.Width / 2)) < Tolerance) { return(true); } } return(false); }
// todo: fix the acurracy public bool IsLowerLinked(InkRecognitionUnit other) { //if (Math.Abs(this.BoundingRect.TopY + this.BoundingRect.Height - other.BoundingRect.TopY) < Tolerance) //{ // if (Math.Abs(this.BoundingRect.TopX + this.BoundingRect.Width / 2 - (other.BoundingRect.TopX + other.BoundingRect.Width / 2)) < Tolerance) // { // return true; // } //} //return false; if (other.BoundingRect.TopX == this.BoundingRect.TopX && other.BoundingRect.TopY == this.BoundingRect.TopY) { return(false); } var dis = DistanceToLower(other); return(dis < Tolerance); }
public bool IsRightMidAligned(InkRecognitionUnit other) { //if (Math.Abs(this.BoundingRect.TopX + this.BoundingRect.Width - other.BoundingRect.TopX) < Tolerance) //{ // if (Math.Abs(this.BoundingRect.TopY + this.BoundingRect.Height / 2 - other.BoundingRect.TopY) < Tolerance) // { // return true; // } //} //return false; if (other.BoundingRect.TopX == this.BoundingRect.TopX && other.BoundingRect.TopY == this.BoundingRect.TopY) { return(false); } var dis = DistanceToRight(other); return(dis < Tolerance); }