public Vector2I Offset(Point2I p) { Point2I o = p - MinPoint; int ox = o.X; int oy = o.Y; if (MaxPoint.X > MinPoint.X) { ox /= (MaxPoint.X - MinPoint.X); } if (MaxPoint.Y > MinPoint.Y) { oy /= (MaxPoint.Y - MinPoint.Y); } return(new Vector2I(ox, oy)); }
public void BoundingSphere(out Point2I c, out int radius) { c = (MinPoint + MaxPoint) / 2; radius = c.IsInside(this) ? c.Distance(MaxPoint) : 0; }
public Bounds2I() { MinPoint = new Point2I(-int.MaxValue, -int.MaxValue); MaxPoint = new Point2I(int.MaxValue, int.MaxValue); }
public Point2I Lerp(Point2I t) { return(new Point2I(PbrtMath.Lerp(t.X, MinPoint.X, MaxPoint.X), PbrtMath.Lerp(t.Y, MinPoint.Y, MaxPoint.Y))); }
public Bounds2I Intersect(Bounds2I b2) { return(new Bounds2I(Point2I.Max(MinPoint, b2.MinPoint), Point2I.Min(MaxPoint, b2.MaxPoint))); }
public Bounds2I(Point2I p1, Point2I p2) { MinPoint = new Point2I(Math.Min(p1.X, p2.X), Math.Min(p1.Y, p2.Y)); MaxPoint = new Point2I(Math.Max(p1.X, p2.X), Math.Max(p1.Y, p2.Y)); }
public int Distance(Point2I p) { return((this - p).Length); }
public Point2I(Point2I other) { X = other.X; Y = other.Y; }
public static Point2I Min(Point2I a, Point2I b) { return(new Point2I(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y))); }
public int AbsDot(Point2I other) { return(Math.Abs(Dot(other))); }
public int Dot(Point2I other) { return(X * other.X + Y * other.Y); }