public static double GetAngleBetweenPointsLineAndHorizontalLine(Vector2 point1, Vector2 point2) { Vector2 body1Origin = new Vector2(point1.X, point1.Y); Vector2 body2Origin = new Vector2(point2.X, point2.Y); MathLine originsLine = new MathLine(body1Origin, body2Origin); return(originsLine.GetAcuteAngle()); }
public override bool ContainsLine(MathLine line) { double distance = line.GetDistanceFromPoint(GetOrigin().X, GetOrigin().Y); if (distance <= Size.X / 2) { return(true); } return(false); }
public Vector2 GetCrossPoint(MathLine line) { if (A - line.A == 0) { return(new Vector2()); } double x = (line.B - B) / (A - line.A); double y = A * x + B; return(new Vector2(x, y)); }
bool isCrossPointOnVerticalSides(MathLine line) { double lineValueLeftSide = line.ValueAt(Position.X); double lineValueRightSide = line.ValueAt(Position.X - Size.X); if ((lineValueLeftSide <= Position.Y && lineValueLeftSide >= Position.Y - Size.Y) || (lineValueRightSide <= Position.Y && lineValueRightSide >= Position.Y - Size.Y)) { return(true); } return(false); }
bool isCrossPointOnHorizontalSides(MathLine line) { List <MathLine> horizontalLines = getHorizontalSidesLines(); List <Vector2> crossPoints = new List <Vector2>(); foreach (MathLine l in horizontalLines) { crossPoints.Add(l.GetCrossPoint(line)); } foreach (Vector2 point in crossPoints) { if (point.X >= Position.X && point.X <= Position.X - Size.X) { return(true); } } return(false); }
public MathLine(MathLine line) { A = line.A; B = line.B; }
public override bool ContainsLine(MathLine line) { return(isCrossPointOnVerticalSides(line) || isCrossPointOnHorizontalSides(line)); }
public abstract bool ContainsLine(MathLine line);