Ejemplo n.º 1
0
        /// <summary>
        /// Get the value of a relativePosition voxel, defined by a Point3i size.
        /// </summary>
        /// <param name="voxelIndex"></param>
        /// <param name="relativePosition"></param>
        /// <returns>
        /// returns 0 if empty
        /// returns -1 if non existant
        /// returns 1 if true
        /// </returns>
        ///
        public sbyte GetRelativePointValue(int voxelIndex, Point3i relativePosition)
        {
            var pt = (Point3i.IndexToPointUvw(SizeUVW, voxelIndex)) + relativePosition;

            if (new Point3i(0, 0, 0) > pt || pt >= SizeUVW)
            {
                return(-1);
            }
            return(GetValue(pt) ? (sbyte)1 : (sbyte)0);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get the value of of a voxel relative to voxel with number i
        /// </summary>
        /// <param name="voxelIndex">The voxel number to get a relative position for</param>
        /// <param name="relativeVoxel">Relative coordinates to the voxel, e.g. (1,0,0) for a voxel to the right</param>
        /// <returns>The value of the relative voxel</returns>
        public float GetRelativePointValue(int voxelIndex, Point3i relativeVoxel)
        {
            var pt = Point3i.IndexToPointUvw(SizeUVW, voxelIndex) + relativeVoxel;

            if (new Point3i(0, 0, 0) > pt || pt >= SizeUVW)
            {
                return(float.NaN);
            }
            return(GetValue(pt));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Set a relativePosition point value to value X
        /// </summary>
        /// <param name="voxelIndex"></param>
        /// <param name="relativePosition"></param>
        /// <param name="value"></param>
        public void SetRelativePointValue(int voxelIndex, Point3i relativePosition, bool value)
        {
            var pt = Point3i.IndexToPointUvw(SizeUVW, voxelIndex) + relativePosition;

            if (new Point3i(0, 0, 0) > pt || pt >= SizeUVW)
            {
                return;
            }

            this[pt] = value;
        }
Ejemplo n.º 4
0
 public bool PointInGrid(Point3i subPt)
 {
     return(!(subPt < Point3i.Origin || subPt >= SizeUVW));
 }
Ejemplo n.º 5
0
 public static Point3i IndexToPointUvw(Point3i gridDimensions, int index)
 {
     return(new Point3i(MatrixHelper.MatrixVector(index, gridDimensions.ToArray())));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Each cell in this grid has a number, the highest number is calculated by cellCount.x*cellCount.y*.cellCount.z)
 /// This method calculates at which number belongs to pointUvw
 ///
 /// This is a 3 dimensions calculation. See also Tools.VectorMatrix method for an n-dimensional implementation
 /// </summary>
 /// <param name="cellCount">Describing the size of a 3-dimensional matrix with cell count x,y,z</param>
 /// <param name="pointUvw">vector describing a u, v, w location in this 3 dimensional grid.  </param>
 /// <returns></returns>
 public static int PointUvwToIndex(Point3i cellCount, Point3i pointUvw)
 {
     return(cellCount.Z * cellCount.Y * pointUvw.X + cellCount.Z * pointUvw.Y + pointUvw.Z);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Is the point3i equal to point p1. Zero tolerance for differences.
 /// </summary>
 /// <param name="p">Point3i to compare with</param>
 /// <returns></returns>
 public bool Equals(Point3i p)
 {
     return(X == p.X && Y == p.Y && Z == p.Z);
 }