public float DistanceOfCar(Car c) { RectangleF rect = GetRectangle(); Rectangle4P r4p = new Rectangle4P(rect); PointF nearestPoint = r4p.GetNearestPointInEdge(c.Position); // return(Calc.Magnitude(c.Position, nearestPoint)); }
public bool IsTowardTrafficLight(Car c) { RectangleF rect = GetRectangle(); Rectangle4P r4p = new Rectangle4P(rect); PointF nearestPoint = r4p.GetNearestPointInEdge(c.Position); // double radErrMargin = Calc.DegreeToRadians(ErrorMargin); double angC_SB = Calc.NormalizeRadian(Calc.GetAngleOfLineBetweenTwoPoints(c.Position, nearestPoint)); // if (Calc.IsInRange(angC_SB - (radErrMargin / 2), angC_SB + (radErrMargin / 2), Calc.NormalizeRadian(c.Angle))) { return(true); } return(false); }
public bool IsAlligned(Car c) { RectangleF rect = GetRectangle(); Rectangle4P r4p = new Rectangle4P(rect); PointF nearestPoint = r4p.GetNearestPointInEdge(c.Position); // double radErrMargin = Calc.DegreeToRadians(ErrorMargin); double angSB_C = Calc.NormalizeRadian(Calc.GetAngleOfLineBetweenTwoPoints(nearestPoint, c.Position)); double tAngle = Calc.NormalizeRadian(Calc.DegreeToRadians(Angle)); double iAngle = Calc.NormalizeRadian(Calc.DegreeToRadians(Angle) - Math.PI); // if (Calc.IsInRange(tAngle - (radErrMargin / 2), tAngle + (radErrMargin / 2), angSB_C) || Calc.IsInRange(iAngle - (radErrMargin / 2), iAngle + (radErrMargin / 2), angSB_C)) { return(true); } return(false); }
public PointF GetNearestPointBetweenTwoRectangles(Rectangle4P r4p) { float dist = Calc.Modulus(Calc.Magnitude(P1, r4p.P1)); PointF np = P1; // for (int C = 1; C <= 4; C++) { PointF CP = GetPointByNumber(C); // for (int D = 1; D <= 4; D++) { float cDist = Calc.Modulus(Calc.Magnitude(CP, r4p.GetPointByNumber(D))); if (cDist < dist) { dist = cDist; np = CP; } } } // return(np); }