Esempio n. 1
0
        public static bool IsInside(XY x, XY y, XY z, XY p)
        {
            Vector2f v1 = new Vector2f(y.GetX() - x.GetX(), y.GetY() - x.GetY());
            Vector2f v2 = new Vector2f(z.GetX() - x.GetX(), z.GetY() - x.GetY());

            float    det    = v1.x * v2.y - v2.x * v1.y;
            Vector2f tmp    = new Vector2f(p.GetX() - x.GetX(), p.GetY() - x.GetY());
            float    lambda = (tmp.x * v2.y - v2.x * tmp.y) / det;
            float    mue    = (v1.x * tmp.y - tmp.x * v1.y) / det;

            return(lambda > 0 && mue > 0 && (lambda + mue) < 1);
        }
Esempio n. 2
0
 public float Side(XY v)
 {
     if (v == null)
     {
         return(0f);
     }
     return(Side(v.GetX(), v.GetY()));
 }
Esempio n. 3
0
 public bool Contains(XY xy)
 {
     if (xy == null)
     {
         return(false);
     }
     return(Contains(xy.GetX(), xy.GetY()));
 }
Esempio n. 4
0
 public AABB SetPosition(XY pos)
 {
     if (pos == null)
     {
         return(this);
     }
     SetPosition(pos.GetX(), pos.GetY());
     return(this);
 }
Esempio n. 5
0
        public float DistanceTo(XY tarGet, bool round)
        {
            if (tarGet == null)
            {
                return(0f);
            }
            float dx = this.x - tarGet.GetX();
            float dy = this.y - tarGet.GetY();

            if (round)
            {
                return(MathUtils.Round(MathUtils.Sqrt(dx * dx + dy * dy)));
            }
            else
            {
                return(MathUtils.Sqrt(dx * dx + dy * dy));
            }
        }
Esempio n. 6
0
 public AABB SetCenter(XY pos)
 {
     SetPosition(pos.GetX() - GetWidth() / 2, pos.GetY() - GetHeight() / 2);
     return(this);
 }
Esempio n. 7
0
 public Line(XY p1, XY p2) : this(p1.GetX(), p1.GetY(), p2.GetX(), p2.GetY())
 {
 }
Esempio n. 8
0
 public static Vector2f At(XY xy)
 {
     return(new Vector2f(xy.GetX(), xy.GetY()));
 }
Esempio n. 9
0
 public Vector2f Set(XY v)
 {
     this.x = v.GetX();
     this.y = v.GetY();
     return(this);
 }