Table of Contents

Class Segment3d

Namespace
Hi.Geom
Assembly
HiGeom.dll

Represents a 3D line segment defined by two endpoints.

public class Segment3d : IExpandToBox3d, IEquatable<Segment3d>, IBinaryIo, IWriteBin, IEnumerable<vec3d_t>, IEnumerable
Inheritance
Segment3d
Implements
Inherited Members
Extension Methods

Constructors

Segment3d()

Initializes a new instance of the Segment3d class with both endpoints unset (NaN), so that HasBothEnds is false until they are assigned.

public Segment3d()

Segment3d(vec3d_t, vec3d_t)

Initializes a new instance of the Segment3d class with endpoints.

public Segment3d(vec3d_t begin, vec3d_t end)

Parameters

begin vec3d_t

Start point

end vec3d_t

End point

Properties

Arrow

Gets the arrow vector from Begin to End.

public vec3d_t Arrow { get; }

Property Value

vec3d_t

Begin

The starting point of the segment.

public vec3d_t Begin { get; set; }

Property Value

vec3d_t

Center

Gets the midpoint of the segment.

public vec3d_t Center { get; }

Property Value

vec3d_t

End

The ending point of the segment.

public vec3d_t End { get; set; }

Property Value

vec3d_t

HasBothEnds

True when both endpoints have been set. An unset endpoint is NaN: a segment read back from a stream whose presence flag was clear, or built with Segment3d() and never assigned, has no endpoints and must not be drawn or measured; this is the one place that decides what “unset” looks like for an endpoint.

public bool HasBothEnds { get; }

Property Value

bool

Length

Gets the length of the segment.

public double Length { get; }

Property Value

double

LengthSquare

The squared length of the segment.

public double LengthSquare { get; }

Property Value

double

Methods

ClosestPoint(vec3d_t)

Gets the closest point on the segment to the specified point.

public vec3d_t ClosestPoint(vec3d_t point)

Parameters

point vec3d_t

Point to find closest point to.

Returns

vec3d_t

Closest point on the segment.

Equals(Segment3d)

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

public bool Equals(Segment3d other)

Parameters

other Segment3d

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.

ExpandToBox3d(ref box3d_t)

Expands the destination box. This function is usually used to compute the bounding box of elements. box3d_t is a value type, so the destination is passed by reference (the C++ expand_to_box3d(box3&) shape); an implementation writes dst = dst.Expanded(...) or forwards ref dst to its parts.

public void ExpandToBox3d(ref box3d_t dst)

Parameters

dst box3d_t

Destination box, expanded in place

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<vec3d_t> GetEnumerator()

Returns

IEnumerator<vec3d_t>

An enumerator that can be used to iterate through the collection.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

PointAt(double)

Gets a point on the segment at the specified parameter t (0 <= t <= 1).

public vec3d_t PointAt(double t)

Parameters

t double

Parameter value between 0 and 1.

Returns

vec3d_t

Point on the segment.

ReadBin(BinaryReader)

Reads binary data to initialize the object.

public void ReadBin(BinaryReader reader)

Parameters

reader BinaryReader

The binary reader to read from

Remarks

A cleared presence flag (written while an endpoint could still be null) reads back as an unset endpoint, NaN.

Swap()

Swaps the begin and end points of the segment.

public void Swap()

ToString()

Returns a string representation of the segment.

public override string ToString()

Returns

string

WriteBin(BinaryWriter)

Writes the object's data to a binary stream.

public void WriteBin(BinaryWriter writer)

Parameters

writer BinaryWriter

The binary writer to write to

Remarks

The presence flag before each endpoint stays in the stream for the old readers and is always true: an unset endpoint is NaN and is written as such.