Table of Contents

Class Cuboidd

Namespace
Vintagestory.API.MathTools
Assembly
VintagestoryAPI.dll

Represents a three dimensional axis-aligned cuboid using two 3d coordinates. Used for collision and selection withes.

public class Cuboidd : IEquatable<Cuboidd>
Inheritance
Cuboidd
Implements
Inherited Members
Extension Methods

Constructors

Cuboidd()

public Cuboidd()

Cuboidd(double, double, double, double, double, double)

public Cuboidd(double x1, double y1, double z1, double x2, double y2, double z2)

Parameters

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

Cuboidd(Vec3d, Vec3d)

public Cuboidd(Vec3d start, Vec3d end)

Parameters

start Vec3d
end Vec3d

Fields

X1

public double X1

Field Value

double

X2

public double X2

Field Value

double

Y1

public double Y1

Field Value

double

Y2

public double Y2

Field Value

double

Z1

public double Z1

Field Value

double

Z2

public double Z2

Field Value

double

Properties

End

public Vec3d End { get; }

Property Value

Vec3d

Height

MaxY-MinY

public double Height { get; }

Property Value

double

Length

MaxZ-MinZ

public double Length { get; }

Property Value

double

MaxX

public double MaxX { get; }

Property Value

double

MaxY

public double MaxY { get; }

Property Value

double

MaxZ

public double MaxZ { get; }

Property Value

double

MinX

public double MinX { get; }

Property Value

double

MinY

public double MinY { get; }

Property Value

double

MinZ

public double MinZ { get; }

Property Value

double

Start

public Vec3d Start { get; }

Property Value

Vec3d

Width

MaxX-MinX

public double Width { get; }

Property Value

double

Methods

Clone()

Creates a copy of the cuboid

public Cuboidd Clone()

Returns

Cuboidd

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(double, double, double)

Returns if the given point is inside the cuboid

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

Parameters

x double
y double
z double

Returns

bool

ContainsOrTouches(IVec3)

Returns if the given point is inside the cuboid

public bool ContainsOrTouches(IVec3 vec)

Parameters

vec IVec3

Returns

bool

Equals(Cuboidd)

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

public bool Equals(Cuboidd other)

Parameters

other Cuboidd

An object to compare with this object.

Returns

bool

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

GrowBy(double, double, double)

public Cuboidd GrowBy(double dx, double dy, double dz)

Parameters

dx double
dy double
dz double

Returns

Cuboidd

GrowToInclude(int, int, int)

Grows the cuboid so that it includes the given block

public Cuboidd GrowToInclude(int x, int y, int z)

Parameters

x int
y int
z int

Returns

Cuboidd

GrowToInclude(IVec3)

Grows the cuboid so that it includes the given block

public Cuboidd GrowToInclude(IVec3 vec)

Parameters

vec IVec3

Returns

Cuboidd

Intersects(Cuboidd)

If the given cuboid intersects with this cuboid

public bool Intersects(Cuboidd other)

Parameters

other Cuboidd

Returns

bool

Intersects(Cuboidf)

If the given cuboid intersects with this cuboid

public bool Intersects(Cuboidf other)

Parameters

other Cuboidf

Returns

bool

Intersects(Cuboidf, double, double, double)

public bool Intersects(Cuboidf other, double offsetx, double offsety, double offsetz)

Parameters

other Cuboidf
offsetx double
offsety double
offsetz double

Returns

bool

Intersects(Cuboidf, Vec3d)

If the given cuboid intersects with this cuboid

public bool Intersects(Cuboidf other, Vec3d offset)

Parameters

other Cuboidf
offset Vec3d

Returns

bool

IntersectsOrTouches(Cuboidd)

If the given cuboid intersects with this cuboid

public bool IntersectsOrTouches(Cuboidd other)

Parameters

other Cuboidd

Returns

bool

IntersectsOrTouches(Cuboidf, double, double, double)

If the given cuboid intersects with this cuboid

public bool IntersectsOrTouches(Cuboidf other, double offsetX, double offsetY, double offsetZ)

Parameters

other Cuboidf
offsetX double
offsetY double
offsetZ double

Returns

bool

IntersectsOrTouches(Cuboidf, Vec3d)

If the given cuboid intersects with this cuboid

public bool IntersectsOrTouches(Cuboidf other, Vec3d offset)

Parameters

other Cuboidf
offset Vec3d

Returns

bool

Offset(double, double, double)

public Cuboidd Offset(double dx, double dy, double dz)

Parameters

dx double
dy double
dz double

Returns

Cuboidd

OffsetCopy(double, double, double)

Returns a new cuboid offseted by given position

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

Parameters

x double
y double
z double

Returns

Cuboidd

OffsetCopy(IVec3)

Returns a new cuboid offseted by given position

public Cuboidd OffsetCopy(IVec3 vec)

Parameters

vec IVec3

Returns

Cuboidd

RemoveRoundingErrors()

public void RemoveRoundingErrors()

RotatedCopy(double, double, double, 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 Cuboidd RotatedCopy(double degX, double degY, double degZ, Vec3d origin)

Parameters

degX double
degY double
degZ double
origin Vec3d

Returns

Cuboidd

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 makes any sense to use this for other rotations than 90 degree intervals.

public Cuboidd RotatedCopy(IVec3 vec, Vec3d origin)

Parameters

vec IVec3
origin Vec3d

Returns

Cuboidd

Set(double, double, double, double, double, double)

Sets the minimum and maximum values of the cuboid

public Cuboidd Set(double x1, double y1, double z1, double x2, double y2, double z2)

Parameters

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

Returns

Cuboidd

Set(Cuboidd)

public void Set(Cuboidd other)

Parameters

other Cuboidd

Set(Cuboidf)

Sets the minimum and maximum values of the cuboid

public Cuboidd Set(Cuboidf selectionBox)

Parameters

selectionBox Cuboidf

Returns

Cuboidd

Set(IVec3, IVec3)

Sets the minimum and maximum values of the cuboid

public Cuboidd Set(IVec3 min, IVec3 max)

Parameters

min IVec3
max IVec3

Returns

Cuboidd

SetAndTranslate(Cuboidf, double, double, double)

Sets the cuboid to the selectionBox, translated by (dX, dY, dZ)

public Cuboidd SetAndTranslate(Cuboidf selectionBox, double dX, double dY, double dZ)

Parameters

selectionBox Cuboidf
dX double
dY double
dZ double

Returns

Cuboidd

SetAndTranslate(Cuboidf, Vec3d)

Sets the cuboid to the selectionBox, translated by vec

public Cuboidd SetAndTranslate(Cuboidf selectionBox, Vec3d vec)

Parameters

selectionBox Cuboidf
vec Vec3d

Returns

Cuboidd

ShortestDistanceFrom(double, double, double)

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

public double ShortestDistanceFrom(double x, double y, double z)

Parameters

x double
y double
z double

Returns

double

ShortestDistanceFrom(Cuboidd)

Returns the shortest distance to any point between this and given cuboid

public double ShortestDistanceFrom(Cuboidd cuboid)

Parameters

cuboid Cuboidd

Returns

double

ShortestDistanceFrom(Cuboidf, BlockPos)

Returns the shortest distance to any point between this and given cuboid

public double ShortestDistanceFrom(Cuboidf cuboid, BlockPos offset)

Parameters

cuboid Cuboidf
offset BlockPos

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

ShortestHorizontalDistanceFrom(double, double)

Returns the shortest horizontal distance to any point between this and given coordinate

public double ShortestHorizontalDistanceFrom(double x, double z)

Parameters

x double
z double

Returns

double

ShortestHorizontalDistanceFrom(Cuboidf, BlockPos)

Returns the shortest horizontal distance to any point between this and given cuboid

public double ShortestHorizontalDistanceFrom(Cuboidf cuboid, BlockPos offset)

Parameters

cuboid Cuboidf
offset BlockPos

Returns

double

ShortestVerticalDistanceFrom(double)

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

public double ShortestVerticalDistanceFrom(double y)

Parameters

y double

Returns

double

ShortestVerticalDistanceFrom(Cuboidd)

Returns the shortest vertical distance to any point between this and given cuboid

public double ShortestVerticalDistanceFrom(Cuboidd cuboid)

Parameters

cuboid Cuboidd

Returns

double

ShortestVerticalDistanceFrom(Cuboidf, EntityPos)

Returns the shortest distance to any point between this and given cuboid

public double ShortestVerticalDistanceFrom(Cuboidf cuboid, EntityPos offset)

Parameters

cuboid Cuboidf
offset EntityPos

Returns

double

ToCuboidi()

public Cuboidi ToCuboidi()

Returns

Cuboidi

ToFloat()

public Cuboidf ToFloat()

Returns

Cuboidf

Translate(double, double, double)

Adds the given offset to the cuboid

public Cuboidd Translate(double posX, double posY, double posZ)

Parameters

posX double
posY double
posZ double

Returns

Cuboidd

Translate(IVec3)

Adds the given offset to the cuboid

public Cuboidd Translate(IVec3 vec)

Parameters

vec IVec3

Returns

Cuboidd

pushOutX(Cuboidd, double, ref EnumPushDirection)

Returns a new x coordinate that's ensured to be outside this cuboid. Used for collision detection.

public double pushOutX(Cuboidd from, double motx, ref EnumPushDirection direction)

Parameters

from Cuboidd
motx double
direction EnumPushDirection

Returns

double

pushOutY(Cuboidd, double, ref EnumPushDirection)

Returns a new y coordinate that's ensured to be outside this cuboid. Used for collision detection.

public double pushOutY(Cuboidd from, double moty, ref EnumPushDirection direction)

Parameters

from Cuboidd
moty double
direction EnumPushDirection

Returns

double

pushOutZ(Cuboidd, double, ref EnumPushDirection)

Returns a new z coordinate that's ensured to be outside this cuboid. Used for collision detection.

public double pushOutZ(Cuboidd from, double motz, ref EnumPushDirection direction)

Parameters

from Cuboidd
motz double
direction EnumPushDirection

Returns

double