public bool IsOnShortLine(clsPoint pt1, double aTol = 0, bool excludeEnds = false) { clsLine l1 = default(clsLine); clsLine l2 = default(clsLine); double d = 0; if (aTol == 0) { aTol = mdlGeometry.myTol; } if (Abs(pt1.Dist(this)) > aTol) { return(false); } l1 = new clsLine(P1, pt1); l2 = Copy(); l2.Normalise(); d = l1.Dot(l2); if (d < -aTol) { return(false); } if (d > Length + aTol) { return(false); } if (excludeEnds && (P1 == pt1 | P2 == pt1)) { return(false); } return(true); }
public clsLine TangentToPointUp(clsPoint pt1) { //Goes on a transition up double a; double x; clsLine l1 = new clsLine(); if (pt1.X < Centre.X + mdlGeometry.myTol) { return(null); } a = Atan((pt1.Y - Centre.Y) / Abs((pt1.X - Centre.X))); x = Radius / pt1.Dist(Centre); if (x >= 1) { return(null); } a = a - Acos(x); l1.P1.X = Centre.X + Radius * Cos(a); l1.P1.Y = Centre.Y + Radius * Sin(a); l1.P2.X = pt1.X; l1.P2.Y = pt1.Y; return(l1); }
private static double DistanceToEllipse(clsPoint pt, RotatedRect rect) { var c = rect.Center; var a = rect.Angle * PI / 180f; pt.Move(-c.X, -c.Y); pt.Rotate(-a); var pt2 = NearestPointOnEllipse(pt, rect.Size.Width / 2, rect.Size.Height / 2); return(pt.Dist(pt2)); }
public bool IsOnLine(clsPoint aPt, double aTol = 0) { if (aTol == 0) { aTol = mdlGeometry.myTol; } if (Abs(aPt.Dist(this)) > aTol) { return(false); } else { return(true); } }
public double DistanceToShortLine(clsPoint pt1) { clsPoint pt2 = default(clsPoint); pt2 = mdlGeometry.ProjectPoint(pt1, this); if (Lambda(pt2) < 0) { pt2 = P1; } if (Lambda(pt2) > 1) { pt2 = P2; } if (mdlGeometry.IsSameDbl(Length, 0)) { pt2 = P1; } return(pt1.Dist(pt2)); }
public clsLine TangentToPoint(clsPoint pt1) { double a; double x; clsLine l1 = new clsLine(); if (pt1.X == Centre.X) { if (pt1.Y > Centre.Y) { a = PI / 2; } else { a = 3 * PI / 2; } } else { a = Atan((pt1.Y - Centre.Y) / Abs((pt1.X - Centre.X))); if (pt1.X > Centre.X) { a = PI - a; } } x = Radius / pt1.Dist(Centre); if (x >= 1) { return(null); } a = a - (Atan(-x / Sqrt(-x * x + 1)) + 2 * Atan(1)); l1.P1.X = Centre.X - Radius * Cos(a); l1.P1.Y = Centre.Y + Radius * Sin(a); l1.P2.X = pt1.X; l1.P2.Y = pt1.Y; //l1.p2.y = l1.p1.y - (pt1.x - l1.p1.x) * Tan((180 - a) * Pi / 180) Angle2 = a; return(l1); }
public clsLine TangentToPointDown(clsPoint pt1) { //Goes on the downside of a transition down double a; double x; clsLine l1; if (pt1.x > Centre.x - mdlGeometry.myTol) { return(null); } a = Atan((Centre.y - pt1.y) / Abs((Centre.x - pt1.x))); x = Radius / pt1.Dist(Centre); if (x >= 1) { return(null); } a = Acos(x) - a; l1 = new clsLine(pt1.Copy(), new clsPoint(Centre.x - Radius * Cos(a), Centre.y + Radius * Sin(a))); return(l1); }
public static clsLine LinePointToTangent(clsPoint p1, clsCircle c1) { double a = 0; double b = 0; double r = 0; double d = 0; clsLine l1 = new clsLine(); clsPoint p2 = new clsPoint(); r = c1.Radius; d = p1.Dist(c1.Centre); if (d < r) { return(null); } a = Asin(r / d); l1 = new clsLine(p1, c1.Centre); b = l1.Angle; p2 = c1.Point(PI / 2 + a + b); return(new clsLine(p1, p2)); }
public bool IsOnHalfLine(clsPoint pt1, double aTol = 0) { clsLine l1 = default(clsLine); clsLine l2 = default(clsLine); double d = 0; if (aTol == 0) { aTol = mdlGeometry.myTol; } if (Abs(pt1.Dist(this)) > aTol) { return(false); } l1 = new clsLine(P1, pt1); l2 = Copy(); l2.Normalise(); d = l1.Dot(l2); if (d < -aTol) { return(false); } return(true); }