示例#1
0
        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));
        }
示例#2
0
 public void BoundingSphere(out Point2I c, out int radius)
 {
     c      = (MinPoint + MaxPoint) / 2;
     radius = c.IsInside(this) ? c.Distance(MaxPoint) : 0;
 }
示例#3
0
 public Bounds2I()
 {
     MinPoint = new Point2I(-int.MaxValue, -int.MaxValue);
     MaxPoint = new Point2I(int.MaxValue, int.MaxValue);
 }
示例#4
0
 public Point2I Lerp(Point2I t)
 {
     return(new Point2I(PbrtMath.Lerp(t.X, MinPoint.X, MaxPoint.X),
                        PbrtMath.Lerp(t.Y, MinPoint.Y, MaxPoint.Y)));
 }
示例#5
0
 public Bounds2I Intersect(Bounds2I b2)
 {
     return(new Bounds2I(Point2I.Max(MinPoint, b2.MinPoint), Point2I.Min(MaxPoint, b2.MaxPoint)));
 }
示例#6
0
 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));
 }
示例#7
0
 public int Distance(Point2I p)
 {
     return((this - p).Length);
 }
示例#8
0
 public Point2I(Point2I other)
 {
     X = other.X;
     Y = other.Y;
 }
示例#9
0
 public static Point2I Min(Point2I a, Point2I b)
 {
     return(new Point2I(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y)));
 }
示例#10
0
 public int AbsDot(Point2I other)
 {
     return(Math.Abs(Dot(other)));
 }
示例#11
0
 public int Dot(Point2I other)
 {
     return(X * other.X + Y * other.Y);
 }