Table of Contents

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

x1 double
x2 double
y1 double
y2 double
z1 double
z2 double

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

x1 float
y1 float
z1 float
x2 float
y2 float
z2 float

Cuboidf(Vec3f, Vec3f)

public Cuboidf(Vec3f start, Vec3f end)

Parameters

start Vec3f
end Vec3f

Fields

X1

Start X Pos

public float X1

Field Value

float

X2

End X Pos

public float X2

Field Value

float

Y1

Start Y Pos

public float Y1

Field Value

float

Y2

End Y Pos

public float Y2

Field Value

float

Z1

Start Z Pos

public float Z1

Field Value

float

Z2

End Z Pos

public float Z2

Field Value

float

Properties

Center

public Vec3d Center { get; }

Property Value

Vec3d

Empty

True when all values are 0

public bool Empty { get; }

Property Value

bool

End

public Vec3f End { get; }

Property Value

Vec3f

Endd

public Vec3d Endd { get; }

Property Value

Vec3d

Height

public float Height { get; }

Property Value

float

this[int]

public float this[int index] { get; set; }

Parameters

index int

Property Value

float

Length

public float Length { get; }

Property Value

float

MaxX

public float MaxX { get; }

Property Value

float

MaxY

public float MaxY { get; }

Property Value

float

MaxZ

public float MaxZ { get; }

Property Value

float

MidX

public float MidX { get; }

Property Value

float

MidY

public float MidY { get; }

Property Value

float

MidZ

public float MidZ { get; }

Property Value

float

MinX

public float MinX { get; }

Property Value

float

MinY

public float MinY { get; }

Property Value

float

MinZ

public float MinZ { get; }

Property Value

float

Start

public Vec3f Start { get; }

Property Value

Vec3f

Startd

public Vec3d Startd { get; }

Property Value

Vec3d

Width

public float Width { get; }

Property Value

float

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

float

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

float

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

float

Methods

ClampTo(Vec3f, Vec3f)

public Cuboidf ClampTo(Vec3f min, Vec3f max)

Parameters

min Vec3f
max Vec3f

Returns

Cuboidf

Clone()

Creates a copy of the cuboid

public Cuboidf Clone()

Returns

Cuboidf

Contains(double, double, double)

Returns if the given point is inside the cuboid

public bool Contains(double x, double y, double z)

Parameters

x double
y double
z double

Returns

bool

ContainsOrTouches(float, float, float)

Returns if the given point is inside the cuboid

public bool ContainsOrTouches(float x, float y, float z)

Parameters

x float
y float
z float

Returns

bool

ContainsOrTouches(IVec3)

Returns if the given point is inside the cuboid

public bool ContainsOrTouches(IVec3 vec)

Parameters

vec IVec3

Returns

bool

ConvertToCuboidi()

public Cuboidi ConvertToCuboidi()

Returns

Cuboidi

Default()

Returns a new cuboid with default size 1 width/height/length

public static Cuboidf Default()

Returns

Cuboidf

Equals(Cuboidf)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(Cuboidf other)

Parameters

other Cuboidf

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Expand(BlockFacing, float)

Expands this in the given direction by amount d

public void Expand(BlockFacing face, float d)

Parameters

face BlockFacing
d 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

x int
y int
z int

Returns

Cuboidf

GrowToInclude(IVec3)

Grows the cuboid so that it includes the given block

public Cuboidf GrowToInclude(IVec3 vec)

Parameters

vec IVec3

Returns

Cuboidf

OffsetCopy(float, float, float)

Returns a new double precision cuboid offseted by given position

public Cuboidf OffsetCopy(float x, float y, float z)

Parameters

x float
y float
z float

Returns

Cuboidf

OffsetCopy(IVec3)

Returns a new cuboid offseted by given position

public Cuboidf OffsetCopy(IVec3 vec)

Parameters

vec IVec3

Returns

Cuboidf

OffsetCopyDouble(double, double, double)

Returns a new cuboid offseted by given position

public Cuboidd OffsetCopyDouble(double x, double y, double z)

Parameters

x double
y double
z double

Returns

Cuboidd

OffsetCopyDouble(IVec3)

Returns a new cuboid offseted by given position

public Cuboidd OffsetCopyDouble(IVec3 vec)

Parameters

vec IVec3

Returns

Cuboidd

OmniGrowBy(float)

public Cuboidf OmniGrowBy(float size)

Parameters

size float

Returns

Cuboidf

OmniNotDownGrowBy(float)

public Cuboidf OmniNotDownGrowBy(float size)

Parameters

size float

Returns

Cuboidf

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

degX float
degY float
degZ float
origin Vec3d

Returns

Cuboidf

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

vec IVec3
origin Vec3d

Returns

Cuboidf

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

x1 float
y1 float
z1 float
x2 float
y2 float
z2 float

Returns

Cuboidf

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

min IVec3
max IVec3

Returns

Cuboidf

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

x float
y float
z float

Returns

double

ShortestDistanceFrom(IVec3)

Returns the shortest distance between given point and any point inside the cuboid

public double ShortestDistanceFrom(IVec3 vec)

Parameters

vec IVec3

Returns

double

ShrinkBy(float)

public Cuboidf ShrinkBy(float size)

Parameters

size float

Returns

Cuboidf

Sub(float, float, float)

Substractes the given offset to the cuboid

public Cuboidf Sub(float posX, float posY, float posZ)

Parameters

posX float
posY float
posZ float

Returns

Cuboidf

Sub(IVec3)

Substractes the given offset to the cuboid

public Cuboidf Sub(IVec3 vec)

Parameters

vec IVec3

Returns

Cuboidf

ToDouble()

public Cuboidd ToDouble()

Returns

Cuboidd

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

Cuboidf

Translate(float, float, float)

Adds the given offset to the cuboid

public Cuboidf Translate(float posX, float posY, float posZ)

Parameters

posX float
posY float
posZ float

Returns

Cuboidf

Translate(IVec3)

Adds the given offset to the cuboid

public Cuboidf Translate(IVec3 vec)

Parameters

vec IVec3

Returns

Cuboidf

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 Cuboidf
x float
direction EnumPushDirection

Returns

double

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 Cuboidf
y float
direction EnumPushDirection

Returns

double

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 Cuboidf
z float
direction EnumPushDirection

Returns

double