Class Cuboidf
- Namespace
- Vintagestory.API.MathTools
- Assembly
- VintagestoryAPI.dll
Represents a three dimensional axis-aligned cuboid using two 3D coordinates. Used for collision and selection boxes.
public class Cuboidf : IEquatable<Cuboidf>
- Inheritance
-
Cuboidf
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
Cuboidf()
public Cuboidf()
Cuboidf(double, double, double, double, double, double)
public Cuboidf(double x1, double x2, double y1, double y2, double z1, double z2)
Parameters
Cuboidf(float)
public Cuboidf(float size)
Parameters
size
float
Cuboidf(float, float, float, float, float, float)
public Cuboidf(float x1, float y1, float z1, float x2, float y2, float z2)
Parameters
Cuboidf(Vec3f, Vec3f)
public Cuboidf(Vec3f start, Vec3f end)
Parameters
Fields
X1
Start X Pos
public float X1
Field Value
X2
End X Pos
public float X2
Field Value
Y1
Start Y Pos
public float Y1
Field Value
Y2
End Y Pos
public float Y2
Field Value
Z1
Start Z Pos
public float Z1
Field Value
Z2
End Z Pos
public float Z2
Field Value
Properties
Center
public Vec3d Center { get; }
Property Value
Empty
True when all values are 0
public bool Empty { get; }
Property Value
End
public Vec3f End { get; }
Property Value
Endd
public Vec3d Endd { get; }
Property Value
Height
public float Height { get; }
Property Value
this[int]
public float this[int index] { get; set; }
Parameters
index
int
Property Value
Length
public float Length { get; }
Property Value
MaxX
public float MaxX { get; }
Property Value
MaxY
public float MaxY { get; }
Property Value
MaxZ
public float MaxZ { get; }
Property Value
MidX
public float MidX { get; }
Property Value
MidY
public float MidY { get; }
Property Value
MidZ
public float MidZ { get; }
Property Value
MinX
public float MinX { get; }
Property Value
MinY
public float MinY { get; }
Property Value
MinZ
public float MinZ { get; }
Property Value
Start
public Vec3f Start { get; }
Property Value
Startd
public Vec3d Startd { get; }
Property Value
Width
public float Width { get; }
Property Value
XSize
This is equivalent to width so long as X2 > X1, but could in theory be a negative number if the box has its corners the wrong way around
public float XSize { get; }
Property Value
YSize
This is equivalent to height so long as Y2 > Y1, but could in theory be a negative number if the box has its corners the wrong way around
public float YSize { get; }
Property Value
ZSize
This is equivalent to length so long as Z2 > Z1, but could in theory be a negative number if the box has its corners the wrong way around
public float ZSize { get; }
Property Value
Methods
ClampTo(Vec3f, Vec3f)
public Cuboidf ClampTo(Vec3f min, Vec3f max)
Parameters
Returns
Clone()
Creates a copy of the cuboid
public Cuboidf Clone()
Returns
Contains(double, double, double)
Returns if the given point is inside the cuboid
public bool Contains(double x, double y, double z)
Parameters
Returns
ContainsOrTouches(float, float, float)
Returns if the given point is inside the cuboid
public bool ContainsOrTouches(float x, float y, float z)
Parameters
Returns
ContainsOrTouches(IVec3)
Returns if the given point is inside the cuboid
public bool ContainsOrTouches(IVec3 vec)
Parameters
vec
IVec3
Returns
ConvertToCuboidi()
public Cuboidi ConvertToCuboidi()
Returns
Default()
Returns a new cuboid with default size 1 width/height/length
public static Cuboidf Default()
Returns
Equals(Cuboidf)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(Cuboidf other)
Parameters
other
CuboidfAn object to compare with this object.
Returns
Expand(BlockFacing, float)
Expands this in the given direction by amount d
public void Expand(BlockFacing face, float d)
Parameters
face
BlockFacingd
float
GrowToInclude(int, int, int)
Grows the cuboid so that it includes the given block
public Cuboidf GrowToInclude(int x, int y, int z)
Parameters
Returns
GrowToInclude(IVec3)
Grows the cuboid so that it includes the given block
public Cuboidf GrowToInclude(IVec3 vec)
Parameters
vec
IVec3
Returns
OffsetCopy(float, float, float)
Returns a new double precision cuboid offseted by given position
public Cuboidf OffsetCopy(float x, float y, float z)
Parameters
Returns
OffsetCopy(IVec3)
Returns a new cuboid offseted by given position
public Cuboidf OffsetCopy(IVec3 vec)
Parameters
vec
IVec3
Returns
OffsetCopyDouble(double, double, double)
Returns a new cuboid offseted by given position
public Cuboidd OffsetCopyDouble(double x, double y, double z)
Parameters
Returns
OffsetCopyDouble(IVec3)
Returns a new cuboid offseted by given position
public Cuboidd OffsetCopyDouble(IVec3 vec)
Parameters
vec
IVec3
Returns
OmniGrowBy(float)
public Cuboidf OmniGrowBy(float size)
Parameters
size
float
Returns
OmniNotDownGrowBy(float)
public Cuboidf OmniNotDownGrowBy(float size)
Parameters
size
float
Returns
RotatedCopy(float, float, float, Vec3d)
Performs a 3-dimensional rotation on the cuboid and returns a new axis-aligned cuboid resulting from this rotation. Not sure it it makes any sense to use this for other rotations than 90 degree intervals.
public Cuboidf RotatedCopy(float degX, float degY, float degZ, Vec3d origin)
Parameters
Returns
RotatedCopy(IVec3, Vec3d)
Performs a 3-dimensional rotation on the cuboid and returns a new axis-aligned cuboid resulting from this rotation. Not sure it it makes any sense to use this for other rotations than 90 degree intervals.
public Cuboidf RotatedCopy(IVec3 vec, Vec3d origin)
Parameters
Returns
RoundToFracsOfOne10thousand()
Makes sure the collisionbox coords are multiples of 0.0001
public void RoundToFracsOfOne10thousand()
Set(float, float, float, float, float, float)
Sets the minimum and maximum values of the cuboid
public Cuboidf Set(float x1, float y1, float z1, float x2, float y2, float z2)
Parameters
Returns
Set(Cuboidf)
public void Set(Cuboidf collisionBox)
Parameters
collisionBox
Cuboidf
Set(IVec3, IVec3)
Sets the minimum and maximum values of the cuboid
public Cuboidf Set(IVec3 min, IVec3 max)
Parameters
Returns
ShortestDistanceFrom(float, float, float)
Returns the shortest distance between given point and any point inside the cuboid
public double ShortestDistanceFrom(float x, float y, float z)
Parameters
Returns
ShortestDistanceFrom(IVec3)
Returns the shortest distance between given point and any point inside the cuboid
public double ShortestDistanceFrom(IVec3 vec)
Parameters
vec
IVec3
Returns
ShrinkBy(float)
public Cuboidf ShrinkBy(float size)
Parameters
size
float
Returns
Sub(float, float, float)
Substractes the given offset to the cuboid
public Cuboidf Sub(float posX, float posY, float posZ)
Parameters
Returns
Sub(IVec3)
Substractes the given offset to the cuboid
public Cuboidf Sub(IVec3 vec)
Parameters
vec
IVec3
Returns
ToDouble()
public Cuboidd ToDouble()
Returns
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
TransformedCopy(float[])
Performs a 3-dimensional rotation on the cuboid and returns a new axis-aligned cuboid resulting from this rotation. Not sure it it makes any sense to use this for other rotations than 90 degree intervals.
public Cuboidf TransformedCopy(float[] matrix)
Parameters
matrix
float[]
Returns
Translate(float, float, float)
Adds the given offset to the cuboid
public Cuboidf Translate(float posX, float posY, float posZ)
Parameters
Returns
Translate(IVec3)
Adds the given offset to the cuboid
public Cuboidf Translate(IVec3 vec)
Parameters
vec
IVec3
Returns
pushOutX(Cuboidf, float, ref EnumPushDirection)
Returns a new x coordinate that's ensured to be outside this cuboid. Used for collision detection.
public double pushOutX(Cuboidf from, float x, ref EnumPushDirection direction)
Parameters
from
Cuboidfx
floatdirection
EnumPushDirection
Returns
pushOutY(Cuboidf, float, ref EnumPushDirection)
Returns a new y coordinate that's ensured to be outside this cuboid. Used for collision detection.
public double pushOutY(Cuboidf from, float y, ref EnumPushDirection direction)
Parameters
from
Cuboidfy
floatdirection
EnumPushDirection
Returns
pushOutZ(Cuboidf, float, ref EnumPushDirection)
Returns a new z coordinate that's ensured to be outside this cuboid. Used for collision detection.
public double pushOutZ(Cuboidf from, float z, ref EnumPushDirection direction)
Parameters
from
Cuboidfz
floatdirection
EnumPushDirection