Beispiel #1
0
        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());
        }
Beispiel #2
0
        public override bool ContainsLine(MathLine line)
        {
            double distance = line.GetDistanceFromPoint(GetOrigin().X, GetOrigin().Y);

            if (distance <= Size.X / 2)
            {
                return(true);
            }

            return(false);
        }
Beispiel #3
0
        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));
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
 public MathLine(MathLine line)
 {
     A = line.A;
     B = line.B;
 }
Beispiel #7
0
 public override bool ContainsLine(MathLine line)
 {
     return(isCrossPointOnVerticalSides(line) || isCrossPointOnHorizontalSides(line));
 }
Beispiel #8
0
 public abstract bool ContainsLine(MathLine line);