protected void SampleProbe(Vector2D point, out Probe probe) { point = Constrain(point - Vector2D.Half * _spacing); Vector2D local = point - _region.TopLeft; Vector2D coord = CgMath.Floor(local / _spacing); int iY = (int)coord.Y * _stride; int iX = (int)coord.X; int iTopLeft = iY + iX; int iTopRight = iY + Math.Min(iX + 1, _stride - 1); int toBottom = (iTopLeft + _stride < _count) ? _stride : 0; Vector2D pTopLeft = CellTopLeft(point); Vector2D d = (point - pTopLeft) / _spacing; probe.TopLeft = _data[iTopLeft]; probe.TopRight = _data[iTopRight]; probe.BottomLeft = _data[iTopLeft + toBottom]; probe.BottomRight = _data[iTopRight + toBottom]; probe.U = d.X; probe.V = d.Y; }
public Vector2D CellTopLeft(Vector2D point) { return(_spacing * CgMath.Floor(point * _toGrid)); }
public Vector2D CellCenter(Vector2D point) { return(_spacing * (CgMath.Floor(point * _toGrid) + Vector2D.Half)); }