Struct box2d_t
Lightweight 2d box: a sequential-layout value type of two vec2d_t fields, the
32-byte mirror of the C++ geom::box2<vec2d>. An orthogonal box whose edges are all
parallel with the Cartesian coordinate axes; the data is Min and Max.
It has no in-place mutating method: write Min/Max on a variable, or
build a new value with Expanded(vec2d_t), Translated(vec2d_t) and the other
value-returning members.
public struct box2d_t : IExpandToBox2d, IEquatable<box2d_t>, IWriteBin, IFormattable
- Implements
- Inherited Members
- Extension Methods
Constructors
box2d_t(params IExpandToBox2d[])
Initializes a new instance of the box2d_t struct that encompasses all the specified objects.
public box2d_t(params IExpandToBox2d[] src)
Parameters
srcIExpandToBox2d[]The objects to include in the box.
box2d_t(vec2d_t, vec2d_t)
Ctor.
public box2d_t(vec2d_t min, vec2d_t max)
Parameters
box2d_t(IEnumerable<IExpandToBox2d>)
Initializes a new instance of the box2d_t struct that encompasses all the objects in the specified collection.
public box2d_t(IEnumerable<IExpandToBox2d> src)
Parameters
srcIEnumerable<IExpandToBox2d>The collection of objects to include in the box.
box2d_t(IEnumerable<vec2d_t>)
Initializes a new instance of the box2d_t struct that encompasses all the points in the specified collection. The value-typed vec2d_t has no covariant path to IEnumerable<T>, and this overload also spares the boxing.
public box2d_t(IEnumerable<vec2d_t> ps)
Parameters
psIEnumerable<vec2d_t>The points to include in the box.
box2d_t(double, double, double, double)
Initializes a new instance of the box2d_t struct with the specified minimum and maximum coordinates.
public box2d_t(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_t(BinaryReader)
Initializes a new instance of the box2d_t struct from binary data.
public box2d_t(BinaryReader reader)
Parameters
readerBinaryReaderThe binary reader to read the data from.
box2d_t(XElement)
Ctor.
public box2d_t(XElement src)
Parameters
srcXElementXML
Fields
Max
Maximum point of the box.
public vec2d_t Max
Field Value
Min
Minimum point of the box.
public vec2d_t Min
Field Value
Properties
Center
Center
public readonly vec2d_t Center { get; }
Property Value
CenterUnitBox
Generate a center unit box which min~max is (-0.5,-0.5)~(0.5,0.5).
public static box2d_t CenterUnitBox { get; }
Property Value
DiagonalLength
Diagonal length.
public readonly double DiagonalLength { get; }
Property Value
Dim
Dimension.
public readonly vec2d_t Dim { get; }
Property Value
HasVolume
Gets a value indicating whether this box has a non-zero volume.
public readonly bool HasVolume { get; }
Property Value
IsAllNaN
Determines whether all coordinates of this box are NaN.
public readonly bool IsAllNaN { get; }
Property Value
IsFinite
True if the box is finite.
public readonly bool IsFinite { get; }
Property Value
IsReversedPoleBox
True if the box is ReversedPoleBox
public readonly bool IsReversedPoleBox { get; }
Property Value
NaN
Generate a nan box which min~max is (nan,nan)~(nan,nan).
public static box2d_t NaN { get; }
Property Value
NativeByteSize
Byte size of the struct as core.dll sees it: sizeof(box2d_t), two vec2d_t.
public static int NativeByteSize { get; }
Property Value
ReversedPoleBox
Generate a reversed pole box which min~max is (∞,∞)~(-∞,-∞).
public static box2d_t ReversedPoleBox { get; }
Property Value
UnitBox
Generate a unit box which min~max is (0,0)~(1,1).
public static box2d_t UnitBox { get; }
Property Value
Volume
Gets the volume (area) of this box.
public readonly 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).
public static box2d_t ZeroBox { get; }
Property Value
Methods
ApexAt(int)
Get Apex at the box.
public readonly vec2d_t ApexAt(int index)
Parameters
indexintindex 0~3. all of 4 apexes.
Returns
Equals(box2d_t)
Indicates whether the current object is equal to another object of the same type.
public readonly bool Equals(box2d_t other)
Parameters
otherbox2d_tAn object to compare with this object.
Returns
Equals(object)
Indicates whether this instance and a specified object are equal.
public override readonly bool Equals(object obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
ExpandToBox2d(ref box2d_t)
Expands the destination box.
This function is usually used to compute the bounding box of elements.
box2d_t is a value type, so the destination is passed by reference
(the C++ expand_to_box2d(box2&) shape).
public readonly void ExpandToBox2d(ref box2d_t dst)
Parameters
dstbox2d_tDestination box, expanded in place
Expanded(box2d_t)
The box expanded to include the specified box.
public readonly box2d_t Expanded(box2d_t src)
Parameters
srcbox2d_tThe box to include.
Returns
- box2d_t
the expanded box
Expanded(vec2d_t)
The box expanded to include the specified point.
public readonly box2d_t Expanded(vec2d_t p)
Parameters
pvec2d_tThe point to include in the box.
Returns
- box2d_t
the expanded box
GetHashCode()
Returns the hash code for this instance.
public override readonly int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
IsOverlapped(box2d_t)
Is the box overlapped to otherBox.
public readonly bool IsOverlapped(box2d_t otherBox)
Parameters
otherBoxbox2d_tother box
Returns
- bool
is overlapped
MakeXmlSource(string)
public readonly XElement MakeXmlSource(string baseDirectory)
Parameters
baseDirectorystring
Returns
ReadBin(BinaryReader)
Reads a box written by WriteBin(BinaryWriter).
public static box2d_t ReadBin(BinaryReader reader)
Parameters
readerBinaryReaderThe binary reader to read the data from.
Returns
- box2d_t
the box
Reg(XFactory)
Registers this type's deserializer with the given XFactory
(or Default when factory is
null). Idempotent.
public static void Reg(XFactory factory = null)
Parameters
factoryXFactory
Scaled(double)
The box scaled from the coordinate origin, i.e. Min * s ~ Max * s.
public readonly box2d_t Scaled(double s)
Parameters
sdoublescale
Returns
- box2d_t
the scaled box
ScaledFromCenter(double)
The box scaled from its center by the specified factor.
public readonly box2d_t ScaledFromCenter(double s)
Parameters
sdoubleThe scale factor.
Returns
- box2d_t
the scaled box
ToString()
Returns the fully qualified type name of this instance.
public override readonly string ToString()
Returns
- string
The fully qualified type name.
ToString(string, IFormatProvider)
Returns a string representation of the box formatted according to the specified format.
public readonly 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
Translated(vec2d_t)
The box translated by vec.
public readonly box2d_t Translated(vec2d_t vec)
Parameters
vecvec2d_ttranslation vector
Returns
- box2d_t
the translated box
WriteBin(BinaryWriter)
Writes the box data to a binary writer.
public readonly void WriteBin(BinaryWriter writer)
Parameters
writerBinaryWriterThe binary writer to write the data to.
Operators
operator ==(box2d_t, box2d_t)
public static bool operator ==(box2d_t left, box2d_t right)
Parameters
Returns
operator !=(box2d_t, box2d_t)
public static bool operator !=(box2d_t left, box2d_t right)