예제 #1
0
 public bool PointingInward(Vector2 position, float angle)
 {
     Velocity tmp = new Velocity(2*(bounds.Width + bounds.Height), angle, true);
     Vector2 limit = tmp.Move(position);
     int clip = 0;
     int count = 0;
     for (int i = 0; i < NumberOfSides(); i++)
     {
         ColisionInfo info = LineManager.LinesIntersect(position, limit, GetCorner(i), GetCorner((i + 1) % NumberOfSides()));
         switch(info.Type)
         {
             case 0:
                 break;
             case 1:
                 if (FloatHelp.ApproxEquals(info.IntersectionPointA.Value, position, .01f))
                 { }
                 else
                 {
                     clip++;
                 }
                 break;
             case 2:
                 break;
             case 3:
                 count++;
                 break;
         }
     }
     return (count + (clip/2)) % 2 == 1;
 }
예제 #2
0
        private static bool PointOnLineSSI(DBLV A, DBLV B, DBLV point)
        {
            bool onX = (point.X >= Math.Min(A.X, B.X) && point.X <= Math.Max(A.X, B.X)) || FloatHelp.ApproxEquals(point.X, A.X, .001) || FloatHelp.ApproxEquals(point.X, B.X, .001);
            bool onY = (point.Y >= Math.Min(A.Y, B.Y) && point.Y <= Math.Max(A.Y, B.Y)) || FloatHelp.ApproxEquals(point.Y, A.Y, .001) || FloatHelp.ApproxEquals(point.Y, B.Y, .001);

            return(onX && onY);
        }
예제 #3
0
 public bool ApproxEquals(DBLV obj, double margin)
 {
     return(FloatHelp.ApproxEquals(this, obj, margin));
 }
예제 #4
0
        private static bool PointOnLineSSI(Vector2 A, Vector2 B, Vector2 point)
        {
            bool onX = (point.X >= Math.Min(A.X, B.X) && point.X <= Math.Max(A.X, B.X)) || FloatHelp.ApproxEquals(point.X, A.X, .001f) || FloatHelp.ApproxEquals(point.X, B.X, .001f);
            bool onY = (point.Y >= Math.Min(A.Y, B.Y) && point.Y <= Math.Max(A.Y, B.Y)) || FloatHelp.ApproxEquals(point.Y, A.Y, .001f) || FloatHelp.ApproxEquals(point.Y, B.Y, .001f);

            return(onX && onY);
        }