Empeld
Empeld plugin documentation.
pluginbase.Helpers.Coords.Volume Struct Reference

Represent a 3D axis-aligned volume More...

Inheritance diagram for pluginbase.Helpers.Coords.Volume:

Public Member Functions

 Volume (Vector3i pt, Size3i size)
 
 Volume (Vector3i pt, int cubeSize)
 
 Volume (int x, int y, int z, int width, int length, int height)
 
 Volume (int x, int y, int z, int cubeSize)
 
Volume NormalForm ()
 Creates the normal-form volume (That is, the size will always be positive) More...
 
bool PointIn (Vector3i pt)
 
bool Intersects (Volume otherVolume)
 Check if this volume intersects the other volume More...
 
override int GetHashCode ()
 
bool Equals (Volume cube)
 
override bool Equals (object obj)
 
override string ToString ()
 

Static Public Member Functions

static Volume RadiusAround (Vector3i pt, int radius)
 Creates a volume around a point, with a radius of size More...
 
static Volume RadiusBelow (Vector3i pt, int radius)
 Creates a volume around a point, with a radius of size, but that doesn't go above a point More...
 
static Volume RadiusPlaneZ (Vector3i pt, int radius, int depth)
 Creates a radius around a plane with a z-depth More...
 
static Volume FromPointCloud (IEnumerable< Vector3i > points)
 From a set of Vector3i points, returns a volume that holds them all. Will have at least size-1 if it has any points . Will be zero, otherwise More...
 
static Volume FromPoints (Vector3i a, Vector3i b)
 Provides a normal-form volume that represents the space between two points More...
 

Public Attributes

Vector3i Point
 
Size3i Size
 
Vector3i Center => new Vector3i(this.Point.X + this.Size.Width / 2, this.Point.Y + this.Size.Length / 2, this.Point.Z + this.Size.Height / 2)
 Approximate center of the volume (integer rounded) More...
 

Static Public Attributes

static readonly Volume Zero = new Volume()
 

Properties

int Left [get]
 
int Right [get]
 
int Bottom [get]
 
int Top [get]
 
int Floor [get]
 
int Ceiling [get]
 
bool IsCubic [get]
 

Detailed Description

Represent a 3D axis-aligned volume

Constructor & Destructor Documentation

◆ Volume() [1/4]

pluginbase.Helpers.Coords.Volume.Volume ( Vector3i  pt,
Size3i  size 
)
60  {
61  Point = pt;
62  Size = size;
63  }
Vector3i Point
Definition: Volume.cs:12
Size3i Size
Definition: Volume.cs:13

◆ Volume() [2/4]

pluginbase.Helpers.Coords.Volume.Volume ( Vector3i  pt,
int  cubeSize 
)
66  {
67  Point = pt;
68  Size = new Size3i(cubeSize);
69  }
Vector3i Point
Definition: Volume.cs:12
Size3i Size
Definition: Volume.cs:13

◆ Volume() [3/4]

pluginbase.Helpers.Coords.Volume.Volume ( int  x,
int  y,
int  z,
int  width,
int  length,
int  height 
)
72  {
73  Point = new Vector3i(x,y,z);
74  Size = new Size3i(width, length, height);
75  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
Vector3i Point
Definition: Volume.cs:12
Size3i Size
Definition: Volume.cs:13

◆ Volume() [4/4]

pluginbase.Helpers.Coords.Volume.Volume ( int  x,
int  y,
int  z,
int  cubeSize 
)
78  {
79  Point = new Vector3i(x,y,z);
80  Size = new Size3i(cubeSize);
81  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
Vector3i Point
Definition: Volume.cs:12
Size3i Size
Definition: Volume.cs:13

Member Function Documentation

◆ Equals() [1/2]

bool pluginbase.Helpers.Coords.Volume.Equals ( Volume  cube)
197  {
198  return this.Size == cube.Size && this.Point == cube.Point;
199  }
Vector3i Point
Definition: Volume.cs:12
Size3i Size
Definition: Volume.cs:13

◆ Equals() [2/2]

override bool pluginbase.Helpers.Coords.Volume.Equals ( object  obj)
202  {
203  if (obj is Volume)
204  {
205  return this.Equals((Volume)obj);
206  }
207  return false;
208  }
bool Equals(Volume cube)
Definition: Volume.cs:196
Volume(Vector3i pt, Size3i size)
Definition: Volume.cs:59

◆ FromPointCloud()

static Volume pluginbase.Helpers.Coords.Volume.FromPointCloud ( IEnumerable< Vector3i points)
static

From a set of Vector3i points, returns a volume that holds them all. Will have at least size-1 if it has any points . Will be zero, otherwise

Returns
The point cloud.
Parameters
pointsPoints.
126  {
127  if (!points.Any())
128  return Volume.Zero;
129 
130  Vector3i min = new Vector3i(int.MaxValue, int.MaxValue, int.MaxValue);
131  Vector3i max = new Vector3i(int.MinValue, int.MinValue, int.MinValue);
132  foreach (Vector3i pt in points)
133  {
134  if (pt.X < min.X) min.X = pt.X;
135  if (pt.Y < min.Y) min.Y = pt.Y;
136  if (pt.Z < min.Z) min.Z = pt.Z;
137 
138  if (pt.X > max.X) max.X = pt.X;
139  if (pt.Y > max.Y) max.Y = pt.Y;
140  if (pt.Z > max.Z) max.Z = pt.Z;
141  }
142  return new Volume(min, (Size3i)(max - min + Vector3i.One));
143  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
Volume(Vector3i pt, Size3i size)
Definition: Volume.cs:59

◆ FromPoints()

static Volume pluginbase.Helpers.Coords.Volume.FromPoints ( Vector3i  a,
Vector3i  b 
)
static

Provides a normal-form volume that represents the space between two points

Returns
The points.
Parameters
aThe alpha component.
bThe blue component.
152  {
153  var a1 = Vector3i.ComponentMin(a, b);
154  var b1 = Vector3i.ComponentMax(a, b);
155  return new Volume(a1, (Size3i)(b1 - a1));
156  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
Volume(Vector3i pt, Size3i size)
Definition: Volume.cs:59

◆ GetHashCode()

override int pluginbase.Helpers.Coords.Volume.GetHashCode ( )
192  {
193  return this.Point.GetHashCode() ^ this.Size.GetHashCode();
194  }
Vector3i Point
Definition: Volume.cs:12
Size3i Size
Definition: Volume.cs:13
override int GetHashCode()
Definition: Size3i.cs:120

◆ Intersects()

bool pluginbase.Helpers.Coords.Volume.Intersects ( Volume  otherVolume)

Check if this volume intersects the other volume

Returns
The intersects.
Parameters
otherVolumeOther volume.
182  {
183  var self = this.NormalForm();
184  var other = otherVolume.NormalForm();
185 
186  return !(self.Left > other.Right || self.Right < other.Left
187  || self.Bottom > other.Top || self.Top < other.Bottom
188  || self.Floor > other.Ceiling || self.Ceiling < other.Floor);
189  }
Volume NormalForm()
Creates the normal-form volume (That is, the size will always be positive)
Definition: Volume.cs:162

◆ NormalForm()

Volume pluginbase.Helpers.Coords.Volume.NormalForm ( )

Creates the normal-form volume (That is, the size will always be positive)

Returns
The form.
163  {
164  return FromPoints(this.Point, this.Point + this.Size);
165  }
Vector3i Point
Definition: Volume.cs:12
static Volume FromPoints(Vector3i a, Vector3i b)
Provides a normal-form volume that represents the space between two points
Definition: Volume.cs:151
Size3i Size
Definition: Volume.cs:13

◆ PointIn()

bool pluginbase.Helpers.Coords.Volume.PointIn ( Vector3i  pt)
168  {
169  return !(
170  pt.X < this.Point.X || pt.X >= this.Point.X + this.Size.Width
171  || pt.Y < this.Point.Y || pt.Y >= this.Point.Y + this.Size.Length
172  || pt.Z < this.Point.Z || pt.Z >= this.Point.Z + this.Size.Height
173  );
174  }
Vector3i Point
Definition: Volume.cs:12
int Height
Definition: Size3i.cs:8
Size3i Size
Definition: Volume.cs:13
int Y
The Y coordinate
Definition: Vector3i.cs:23
int Width
Definition: Size3i.cs:8
int Length
Definition: Size3i.cs:8
int X
The X coordinate
Definition: Vector3i.cs:18
int Z
The Z coordinate
Definition: Vector3i.cs:28

◆ RadiusAround()

static Volume pluginbase.Helpers.Coords.Volume.RadiusAround ( Vector3i  pt,
int  radius 
)
static

Creates a volume around a point, with a radius of size

Returns
The around.
Parameters
ptPoint.
radiusSize.
92  {
93  return new Volume(pt.X - radius, pt.Y - radius, pt.Z - radius, radius*2);
94  }
Volume(Vector3i pt, Size3i size)
Definition: Volume.cs:59

◆ RadiusBelow()

static Volume pluginbase.Helpers.Coords.Volume.RadiusBelow ( Vector3i  pt,
int  radius 
)
static

Creates a volume around a point, with a radius of size, but that doesn't go above a point

Returns
The below.
Parameters
ptPoint.
radiusSize.
103  {
104  return new Volume(pt.X - radius, pt.Y - radius, pt.Z - radius, radius*2, radius*2, radius);
105  }
Volume(Vector3i pt, Size3i size)
Definition: Volume.cs:59

◆ RadiusPlaneZ()

static Volume pluginbase.Helpers.Coords.Volume.RadiusPlaneZ ( Vector3i  pt,
int  radius,
int  depth 
)
static

Creates a radius around a plane with a z-depth

Returns
The z.
Parameters
ptPoint.
radiusRadius.
depthDepth.
115  {
116  return new Volume(pt.X - radius, pt.Y - radius, pt.Z, radius * 2, radius * 2, depth);
117  }
Volume(Vector3i pt, Size3i size)
Definition: Volume.cs:59

◆ ToString()

override string pluginbase.Helpers.Coords.Volume.ToString ( )
211  {
212  return string.Format("[Volume: Point={0}, Size={1}]", Point, Size);
213  }
Vector3i Point
Definition: Volume.cs:12
Size3i Size
Definition: Volume.cs:13

Member Data Documentation

◆ Center

Vector3i pluginbase.Helpers.Coords.Volume.Center => new Vector3i(this.Point.X + this.Size.Width / 2, this.Point.Y + this.Size.Length / 2, this.Point.Z + this.Size.Height / 2)

Approximate center of the volume (integer rounded)

The center.

◆ Point

Vector3i pluginbase.Helpers.Coords.Volume.Point

◆ Size

Size3i pluginbase.Helpers.Coords.Volume.Size

◆ Zero

readonly Volume pluginbase.Helpers.Coords.Volume.Zero = new Volume()
static

Property Documentation

◆ Bottom

int pluginbase.Helpers.Coords.Volume.Bottom
get

◆ Ceiling

int pluginbase.Helpers.Coords.Volume.Ceiling
get

◆ Floor

int pluginbase.Helpers.Coords.Volume.Floor
get

◆ IsCubic

bool pluginbase.Helpers.Coords.Volume.IsCubic
get

◆ Left

int pluginbase.Helpers.Coords.Volume.Left
get

◆ Right

int pluginbase.Helpers.Coords.Volume.Right
get

◆ Top

int pluginbase.Helpers.Coords.Volume.Top
get

The documentation for this struct was generated from the following file: