Table of Contents

Struct box2d_t

Namespace
Hi.Geom
Assembly
HiGeom.dll

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

src IExpandToBox2d[]

The objects to include in the box.

box2d_t(vec2d_t, vec2d_t)

Ctor.

public box2d_t(vec2d_t min, vec2d_t max)

Parameters

min vec2d_t

Min

max vec2d_t

Max

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

src IEnumerable<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

ps IEnumerable<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

minx double

The minimum X coordinate.

miny double

The minimum Y coordinate.

maxx double

The maximum X coordinate.

maxy double

The maximum Y coordinate.

box2d_t(BinaryReader)

Initializes a new instance of the box2d_t struct from binary data.

public box2d_t(BinaryReader reader)

Parameters

reader BinaryReader

The binary reader to read the data from.

box2d_t(XElement)

Ctor.

public box2d_t(XElement src)

Parameters

src XElement

XML

Fields

Max

Maximum point of the box.

public vec2d_t Max

Field Value

vec2d_t

Min

Minimum point of the box.

public vec2d_t Min

Field Value

vec2d_t

Properties

Center

Center

public readonly vec2d_t Center { get; }

Property Value

vec2d_t

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

box2d_t

DiagonalLength

Diagonal length.

public readonly double DiagonalLength { get; }

Property Value

double

Dim

Dimension.

public readonly vec2d_t Dim { get; }

Property Value

vec2d_t

HasVolume

Gets a value indicating whether this box has a non-zero volume.

public readonly bool HasVolume { get; }

Property Value

bool

IsAllNaN

Determines whether all coordinates of this box are NaN.

public readonly bool IsAllNaN { get; }

Property Value

bool

IsFinite

True if the box is finite.

public readonly bool IsFinite { get; }

Property Value

bool

IsReversedPoleBox

True if the box is ReversedPoleBox

public readonly bool IsReversedPoleBox { get; }

Property Value

bool

NaN

Generate a nan box which min~max is (nan,nan)~(nan,nan).

public static box2d_t NaN { get; }

Property Value

box2d_t

NativeByteSize

Byte size of the struct as core.dll sees it: sizeof(box2d_t), two vec2d_t.

public static int NativeByteSize { get; }

Property Value

int

ReversedPoleBox

Generate a reversed pole box which min~max is (∞,∞)~(-∞,-∞).

public static box2d_t ReversedPoleBox { get; }

Property Value

box2d_t

UnitBox

Generate a unit box which min~max is (0,0)~(1,1).

public static box2d_t UnitBox { get; }

Property Value

box2d_t

Volume

Gets the volume (area) of this box.

public readonly double Volume { get; }

Property Value

double

XName

Name for XML IO.

public static string XName { get; }

Property Value

string

ZeroBox

Generate a zero box which min~max is (0,0)~(0,0).

public static box2d_t ZeroBox { get; }

Property Value

box2d_t

Methods

ApexAt(int)

Get Apex at the box.

public readonly vec2d_t ApexAt(int index)

Parameters

index int

index 0~3. all of 4 apexes.

Returns

vec2d_t

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

other box2d_t

An object to compare with this object.

Returns

bool

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

Equals(object)

Indicates whether this instance and a specified object are equal.

public override readonly bool Equals(object obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and 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

dst box2d_t

Destination box, expanded in place

Expanded(box2d_t)

The box expanded to include the specified box.

public readonly box2d_t Expanded(box2d_t src)

Parameters

src box2d_t

The 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

p vec2d_t

The 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

otherBox box2d_t

other box

Returns

bool

is overlapped

MakeXmlSource(string)

public readonly XElement MakeXmlSource(string baseDirectory)

Parameters

baseDirectory string

Returns

XElement

ReadBin(BinaryReader)

Reads a box written by WriteBin(BinaryWriter).

public static box2d_t ReadBin(BinaryReader reader)

Parameters

reader BinaryReader

The 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

factory XFactory

Scaled(double)

The box scaled from the coordinate origin, i.e. Min * s ~ Max * s.

public readonly box2d_t Scaled(double s)

Parameters

s double

scale

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

s double

The 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

format string

The format to use for each component

formatProvider IFormatProvider

The 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

vec vec2d_t

translation vector

Returns

box2d_t

the translated box

WriteBin(BinaryWriter)

Writes the box data to a binary writer.

public readonly void WriteBin(BinaryWriter writer)

Parameters

writer BinaryWriter

The binary writer to write the data to.

Operators

operator ==(box2d_t, box2d_t)

public static bool operator ==(box2d_t left, box2d_t right)

Parameters

left box2d_t
right box2d_t

Returns

bool

operator !=(box2d_t, box2d_t)

public static bool operator !=(box2d_t left, box2d_t right)

Parameters

left box2d_t
right box2d_t

Returns

bool