Table of Contents

Class Box2d

Namespace
Hi.Geom
Assembly
HiGeom.dll

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)

Ctor. The Ctor keeps Min and Max to null.

public Box2d(Box2d.NoInit noInit)

Parameters

noInit Box2d.NoInit

Box2d(params IExpandToBox2d[])

Initializes a new instance of the Box2d class that encompasses all the specified objects.

public Box2d(params IExpandToBox2d[] src)

Parameters

src IExpandToBox2d[]

The objects to include in the box.

Box2d(Vec2d, Vec2d)

Ctor.

public Box2d(Vec2d min, Vec2d max)

Parameters

min Vec2d

Min

max Vec2d

Max

Box2d(box2d)

Ctor.

public Box2d(box2d src)

Parameters

src box2d

src

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

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

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(BinaryReader)

Initializes a new instance of the Box2d class from binary data.

public Box2d(BinaryReader reader)

Parameters

reader BinaryReader

The binary reader to read the data from.

Box2d(XElement)

Ctor.

public Box2d(XElement src)

Parameters

src XElement

XML

Properties

Center

Center

public Vec2d Center { get; }

Property Value

Vec2d

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

Box2d

DiagonalLength

Diagonal length.

public double DiagonalLength { get; }

Property Value

double

Dim

Dimension.

public Vec2d Dim { get; }

Property Value

Vec2d

HasVolume

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

public bool HasVolume { get; }

Property Value

bool

IsAllNaN

Determines whether all coordinates of this box are NaN.

public bool IsAllNaN { get; }

Property Value

bool

IsFinite

True if the box is finite.

public bool IsFinite { get; }

Property Value

bool

IsReversedPoleBox

True if the box is ReversedPoleBox

public bool IsReversedPoleBox { get; }

Property Value

bool

Max

Maximum point of the box.

public Vec2d Max { get; set; }

Property Value

Vec2d

Min

Minimum point of the box.

public Vec2d Min { get; set; }

Property Value

Vec2d

NaN

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

public static Box2d NaN { get; }

Property Value

Box2d

NativeByteSize

Gets the size in bytes of the native representation of this box.

public static int NativeByteSize { get; }

Property Value

int

ReversedPoleBox

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

public static Box2d ReversedPoleBox { get; }

Property Value

Box2d

UnitBox

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

public static Box2d UnitBox { get; }

Property Value

Box2d

Volume

Gets the volume (area) of this box.

public 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,0,0).

public static Box2d ZeroBox { get; }

Property Value

Box2d

Methods

ApexAt(int)

Get Apex at the box.

public Vec2d ApexAt(int index)

Parameters

index int

index 0~7. all of 8 apex.

Returns

Vec2d

Equals(Box2d)

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

public bool Equals(Box2d other)

Parameters

other Box2d

An object to compare with this object.

Returns

bool

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

Equals(object)

Determines whether the specified object is equal to the current object.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

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

Expand(Box2d)

Expands this box to include the specified box.

public Box2d Expand(Box2d src)

Parameters

src Box2d

The 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

p Vec2d

The 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

dst Box2d

The 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

otherBox Box2d

other box

Returns

bool

is overlapped

MakeXmlSource(string)

public XElement MakeXmlSource(string baseDirectory)

Parameters

baseDirectory string

Returns

XElement

ReadBin(BinaryReader)

Reads binary data to initialize the object.

public void ReadBin(BinaryReader reader)

Parameters

reader BinaryReader

The 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

s double

scale

Returns

Box2d

this

ScaleFromCenter(double)

Scales this box from its center by the specified factor.

public Box2d ScaleFromCenter(double s)

Parameters

s double

The scale factor.

Returns

Box2d

This box instance after scaling.

Set(Box2d)

Copy the src. The Min and Max are kept the same object. Only the double values changed.

public Box2d Set(Box2d src)

Parameters

src Box2d

src

Returns

Box2d

this

Set(box2d)

Copy the src. The Min and Max are kept the same object. Only the double values changed.

public Box2d Set(box2d src)

Parameters

src box2d

src

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

minx double

The minimum X coordinate.

miny double

The minimum Y coordinate.

maxx double

The maximum X coordinate.

maxy double

The 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

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

Translate(Vec2d)

Translate the box.

public Box2d Translate(Vec2d vec)

Parameters

vec Vec2d

translation vector

Returns

Box2d

this

WriteBin(BinaryWriter)

Writes the box data to a binary writer.

public void WriteBin(BinaryWriter writer)

Parameters

writer BinaryWriter

The binary writer to write the data to.