Advertisement
Advertisement
| 05.22.2008 at 10:04AM PDT, ID: 23425138 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: |
protected Point[] GetSegmentBounds(Point p1, Point p2, Double offset)
{
Point[] rect = new Point[4];
Double len = Math.Sqrt((Double)((p1.X - p2.X) * (p1.X - p2.X) + (p1.Y - p2.Y) * (p1.Y - p2.Y)));// +(offset * 2);
rect[0].X = (Int32)(p1.X - (p1.Y - p2.Y) * offset / len);
rect[0].Y = (Int32)(p1.Y + (p1.X - p2.X) * offset / len);
rect[1].X = (Int32)(p1.X + (p1.Y - p2.Y) * offset / len);
rect[1].Y = (Int32)(p1.Y - (p1.X - p2.X) * offset / len);
rect[2].X = (Int32)(p2.X + (p1.Y - p2.Y) * offset / len);
rect[2].Y = (Int32)(p2.Y - (p1.X - p2.X) * offset / len);
rect[3].X = (Int32)(p2.X - (p1.Y - p2.Y) * offset / len);
rect[3].Y = (Int32)(p2.Y + (p1.X - p2.X) * offset / len);
return rect;
}
|