Class Box2d
Lightweight 2d box. An orthogonal box which the edges are all parallel with Cartesian Coordinate. The data contains in a Box2d is Min and Max.
public class Box2d : IExpandToBox2d, IEquatable<Box2d>, IBinaryIo, IWriteBin, IFormattable
- Inheritance
-
Box2d
- Implements
- Inherited Members
- Extension Methods
Constructors
Box2d()
Ctor.
public Box2d()
Box2d(NoInit)
public Box2d(Box2d.NoInit noInit)
Parameters
Box2d(params IExpandToBox2d[])
Initializes a new instance of the Box2d class that encompasses all the specified objects.
public Box2d(params IExpandToBox2d[] src)
Parameters
srcIExpandToBox2d[]The objects to include in the box.
Box2d(Vec2d, Vec2d)
Ctor.
public Box2d(Vec2d min, Vec2d max)
Parameters
Box2d(box2d)
Ctor.
public Box2d(box2d src)
Parameters
srcbox2dsrc
Box2d(IEnumerable<IExpandToBox2d>)
Initializes a new instance of the Box2d class that encompasses all the objects in the specified collection.
public Box2d(IEnumerable<IExpandToBox2d> src)
Parameters
srcIEnumerable<IExpandToBox2d>The collection of objects to include in the box.
Box2d(double, double, double, double)
Initializes a new instance of the Box2d class with the specified minimum and maximum coordinates.
public Box2d(double minx, double miny, double maxx, double maxy)
Parameters
minxdoubleThe minimum X coordinate.
minydoubleThe minimum Y coordinate.
maxxdoubleThe maximum X coordinate.
maxydoubleThe maximum Y coordinate.
Box2d(BinaryReader)
Initializes a new instance of the Box2d class from binary data.
public Box2d(BinaryReader reader)
Parameters
readerBinaryReaderThe binary reader to read the data from.
Box2d(XElement)
Ctor.
public Box2d(XElement src)
Parameters
srcXElementXML
Properties
Center
Center
public Vec2d Center { get; }
Property Value
CenterUnitBox
Generate a center unit box which min~max is (-0.5,-0.5,-0.5)~(-0.5,0.5,0.5).
public static Box2d CenterUnitBox { get; }
Property Value
DiagonalLength
Diagonal length.
public double DiagonalLength { get; }
Property Value
Dim
Dimension.
public Vec2d Dim { get; }
Property Value
HasVolume
Gets a value indicating whether this box has a non-zero volume.
public bool HasVolume { get; }
Property Value
IsAllNaN
Determines whether all coordinates of this box are NaN.
public bool IsAllNaN { get; }
Property Value
IsFinite
True if the box is finite.
public bool IsFinite { get; }
Property Value
IsReversedPoleBox
True if the box is ReversedPoleBox
public bool IsReversedPoleBox { get; }
Property Value
Max
Maximum point of the box.
public Vec2d Max { get; set; }
Property Value
Min
Minimum point of the box.
public Vec2d Min { get; set; }
Property Value
NaN
Generate a nan box which min~max is (nan,nan,nan)~(nan,nan,nan).
public static Box2d NaN { get; }
Property Value
NativeByteSize
Gets the size in bytes of the native representation of this box.
public static int NativeByteSize { get; }
Property Value
ReversedPoleBox
Generate a reversed pole box which min~max is (∞,∞,∞)~(-∞,-∞,-∞).
public static Box2d ReversedPoleBox { get; }
Property Value
UnitBox
Generate a unit box which min~max is (0,0,0)~(1,1,1).
public static Box2d UnitBox { get; }
Property Value
Volume
Gets the volume (area) of this box.
public double Volume { get; }
Property Value
XName
Name for XML IO.
public static string XName { get; }
Property Value
ZeroBox
Generate a zero box which min~max is (0,0,0)~(0,0,0).
public static Box2d ZeroBox { get; }
Property Value
Methods
ApexAt(int)
Get Apex at the box.
public Vec2d ApexAt(int index)
Parameters
indexintindex 0~7. all of 8 apex.
Returns
Equals(Box2d)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(Box2d other)
Parameters
otherBox2dAn object to compare with this object.
Returns
Equals(object)
Determines whether the specified object is equal to the current object.
public override bool Equals(object obj)
Parameters
objobjectThe object to compare with the current object.
Returns
Expand(Box2d)
Expands this box to include the specified box.
public Box2d Expand(Box2d src)
Parameters
srcBox2dThe box to include.
Returns
- Box2d
This box instance after expansion.
Expand(Vec2d)
Expands this box to include the specified point.
public Box2d Expand(Vec2d p)
Parameters
pVec2dThe point to include in the box.
Returns
- Box2d
This box instance after expansion.
ExpandToBox2d(Box2d)
Expands the specified destination box to include this box.
public void ExpandToBox2d(Box2d dst)
Parameters
dstBox2dThe destination box to expand.
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
IsOverlapped(Box2d)
Is the box overlapped to otherBox.
public bool IsOverlapped(Box2d otherBox)
Parameters
otherBoxBox2dother box
Returns
- bool
is overlapped
MakeXmlSource(string)
public XElement MakeXmlSource(string baseDirectory)
Parameters
baseDirectorystring
Returns
ReadBin(BinaryReader)
Reads binary data to initialize the object.
public void ReadBin(BinaryReader reader)
Parameters
readerBinaryReaderThe binary reader to read from
Scale(double)
Scale the box from the coordinate origin. The operation is equal to:
Min *= s;
Max *= s;
public Box2d Scale(double s)
Parameters
sdoublescale
Returns
- Box2d
this
ScaleFromCenter(double)
Scales this box from its center by the specified factor.
public Box2d ScaleFromCenter(double s)
Parameters
sdoubleThe scale factor.
Returns
- Box2d
This box instance after scaling.
Set(Box2d)
public Box2d Set(Box2d src)
Parameters
srcBox2dsrc
Returns
- Box2d
this
Set(box2d)
public Box2d Set(box2d src)
Parameters
srcbox2dsrc
Returns
- Box2d
this
Set(double, double, double, double)
Sets the minimum and maximum coordinates of this box.
public Box2d Set(double minx, double miny, double maxx, double maxy)
Parameters
minxdoubleThe minimum X coordinate.
minydoubleThe minimum Y coordinate.
maxxdoubleThe maximum X coordinate.
maxydoubleThe maximum Y coordinate.
Returns
- Box2d
This box instance.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
ToString(string, IFormatProvider)
Returns a string representation of the box formatted according to the specified format.
public string ToString(string format, IFormatProvider formatProvider)
Parameters
formatstringThe format to use for each component
formatProviderIFormatProviderThe format provider to use
Returns
- string
A formatted string representation of the box
Translate(Vec2d)
Translate the box.
public Box2d Translate(Vec2d vec)
Parameters
vecVec2dtranslation vector
Returns
- Box2d
this
WriteBin(BinaryWriter)
Writes the box data to a binary writer.
public void WriteBin(BinaryWriter writer)
Parameters
writerBinaryWriterThe binary writer to write the data to.