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); }
public float Side(XY v) { if (v == null) { return(0f); } return(Side(v.GetX(), v.GetY())); }
public bool Contains(XY xy) { if (xy == null) { return(false); } return(Contains(xy.GetX(), xy.GetY())); }
public AABB SetPosition(XY pos) { if (pos == null) { return(this); } SetPosition(pos.GetX(), pos.GetY()); return(this); }
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)); } }
public AABB SetCenter(XY pos) { SetPosition(pos.GetX() - GetWidth() / 2, pos.GetY() - GetHeight() / 2); return(this); }
public Line(XY p1, XY p2) : this(p1.GetX(), p1.GetY(), p2.GetX(), p2.GetY()) { }
public static Vector2f At(XY xy) { return(new Vector2f(xy.GetX(), xy.GetY())); }
public Vector2f Set(XY v) { this.x = v.GetX(); this.y = v.GetY(); return(this); }