/// <summary> /// /// </summary> /// <param name="iVx"></param> /// <param name="ptRelVx"></param> /// <returns></returns> public Point2i GetRelativeUV(int iVx, Point2i ptRelVx) { var pt = IndexUV(iVx) + ptRelVx; if (new Point2i(0, 0) > pt || pt >= SizeUV) { throw new Exception("Index does not exist"); } return(pt); }
private void Initialize(Rectangle3d boundingBox, Point2d pixelDimensions) { _BBox = boundingBox; _PixelSize = pixelDimensions; int iX = Convert.ToInt16(Math.Floor(boundingBox.X.Length / pixelDimensions.X)); int iY = Convert.ToInt16(Math.Floor(boundingBox.Y.Length / pixelDimensions.Y)); var size = new Point2i(iX, iY); SizeUV = size; }
/// <summary> /// Construct a pixelgrid /// </summary> /// <param name="boundingBox"></param> /// <param name="pxielDimensions"></param> /// <param name="grid"></param> public Grid2D(Rectangle3d boundingBox, Point2d pxielDimensions, T grid) : base() { _BBox = boundingBox; _PixelSize = pxielDimensions; int iX = Convert.ToInt16(Math.Floor(boundingBox.X.Length / pxielDimensions.X)); int iY = Convert.ToInt16(Math.Floor(boundingBox.Y.Length / pxielDimensions.Y)); var gridsize = new Point2i(iX, iY); SizeUV = gridsize; Grid = grid; }
/// <summary> /// Is the point2i equal to point p1. Zero tolerance for differences. /// </summary> /// <param name="p">Point2i to compare with</param> /// <returns></returns> public bool Equals(Point2i p) { return(X == p.X && Y == p.Y); }
/// <summary> /// Return a value at index /// </summary> /// <param name="index"></param> /// <returns></returns> public Y ValueAt(Point2i index) { return(ValueAt(UVIndex(index))); }
/// <summary> /// Convert a point2i location to the index of the point in the bitarray /// </summary> /// <param name="uv"></param> /// <returns></returns> public int UVIndex(Point2i uv) { return(uv ^ _SizeUV); }