Table of Contents

Struct tri3d_t

Namespace
Hi.Geom
Assembly
HiGeom.dll

Basic 3D triangle: a sequential-layout value type of four vec3d_t fields in the order p0, p1, p2, n, the 96-byte mirror of the C++ geom::tri3<vec3d_t> (so a pinned array of triangles is what core.dll reads as tri3d_t*). It has no in-place mutating method: write an apex through the fields or the indexer on a variable, field or array element (never on a property or a List indexer, which hand out a copy), or build a new value with the Get* members.

public struct tri3d_t : ITri3d, IFlat3d, IExpandToBox3d, IEquatable<tri3d_t>, IWriteBin
Implements
Inherited Members
Extension Methods

Constructors

tri3d_t(ITri3d)

Creates a triangle from an ITri3d interface

public tri3d_t(ITri3d t)

Parameters

t ITri3d

The source triangle implementing ITri3d

tri3d_t(ITri3d, Mat4d)

Creates a triangle from an ITri3d interface and transforms it using a matrix; the normal is recomputed from the transformed apexes.

public tri3d_t(ITri3d t, Mat4d mat)

Parameters

t ITri3d

The source triangle implementing ITri3d

mat Mat4d

The transformation matrix to apply

tri3d_t(tri3d_t)

Copy ctor. Assignment copies a tri3d_t just as well; this overload stays for the call sites that spell the copy out.

public tri3d_t(tri3d_t t)

Parameters

t tri3d_t

The source triangle

tri3d_t(vec3d_t, vec3d_t, vec3d_t)

Ctor. The normal is computed from the apexes.

public tri3d_t(vec3d_t p0, vec3d_t p1, vec3d_t p2)

Parameters

p0 vec3d_t

apex0

p1 vec3d_t

apex1

p2 vec3d_t

apex2

tri3d_t(vec3d_t, vec3d_t, vec3d_t, vec3d_t)

Creates a triangle with the specified vertices and normal vector

public tri3d_t(vec3d_t p0, vec3d_t p1, vec3d_t p2, vec3d_t n)

Parameters

p0 vec3d_t

First vertex

p1 vec3d_t

Second vertex

p2 vec3d_t

Third vertex

n vec3d_t

Normal vector

tri3d_t(BinaryReader)

Creates a triangle by reading its data from a binary reader

public tri3d_t(BinaryReader reader)

Parameters

reader BinaryReader

The binary reader to read from

Fields

n

Normal vector of this triangle. Every constructor assigns it (computed from the apexes when not given), so it is never absent; GetNormalRebuilt() recomputes it after the apexes change.

public vec3d_t n

Field Value

vec3d_t

p0

Apex 0.

public vec3d_t p0

Field Value

vec3d_t

p1

Apex 1.

public vec3d_t p1

Field Value

vec3d_t

p2

Apex 2.

public vec3d_t p2

Field Value

vec3d_t

Properties

Apexes

The three apexes in order.

public readonly IEnumerable<vec3d_t> Apexes { get; }

Property Value

IEnumerable<vec3d_t>

Area

Gets the area of the triangle

public readonly double Area { get; }

Property Value

double

this[int]

The apex at i (0, 1 or 2). The setter writes the field directly, so it works on a variable, field or array element and is a compile error (CS1612) on a property receiver.

public vec3d_t this[int i] { readonly get; set; }

Parameters

i int

apex index

Property Value

vec3d_t

NativeByteSize

Byte size of the struct as core.dll sees it: sizeof(tri3d_t), four vec3d_t.

public static int NativeByteSize { get; }

Property Value

int

Methods

BuildNormal(vec3d_t, vec3d_t, vec3d_t)

The unit normal of the triangle (p0, p1, p2), i.e. the normalized cross product of the two edges leaving p0.

public static vec3d_t BuildNormal(vec3d_t p0, vec3d_t p1, vec3d_t p2)

Parameters

p0 vec3d_t

apex0

p1 vec3d_t

apex1

p2 vec3d_t

apex2

Returns

vec3d_t

the unit normal (NaN for a degenerate triangle)

Equals(tri3d_t)

Value equality over the four vectors (the three apexes and the normal).

public readonly bool Equals(tri3d_t other)

Parameters

other tri3d_t

other triangle

Returns

bool

true when all four vectors are equal

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.

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 readonly void ExpandToBox3d(ref box3d_t dst)

Parameters

dst box3d_t

Destination box, expanded in place

GetApex(int)

Gets the specified vertex (apex) of this triangle.

public readonly vec3d_t GetApex(int i)

Parameters

i int

Index of the vertex (0-2)

Returns

vec3d_t

The position of the specified vertex

GetBuiltNormal()

The normal rebuilt from the apexes (what n would be if it had been computed).

public readonly vec3d_t GetBuiltNormal()

Returns

vec3d_t

the rebuilt unit normal

GetDistanceToOrigin()

Signed Distance To Origin.

public readonly double GetDistanceToOrigin()

Returns

double

Signed Distance To Origin.

GetEdgeArrow(int)

Gets the edge vector from vertex i to vertex i+1.

public readonly vec3d_t GetEdgeArrow(int i)

Parameters

i int

The index of the starting vertex (0, 1, or 2).

Returns

vec3d_t

The vector representing the edge.

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.

GetLocate()

Gets an anchor point on this flat surface.

public readonly vec3d_t GetLocate()

Returns

vec3d_t

A point on the flat surface

GetNormal()

Gets the normal vector of the flat surface.

public readonly vec3d_t GetNormal()

Returns

vec3d_t

The unit normal vector

GetNormalRebuilt()

This triangle with its normal rebuilt from the apexes.

public readonly tri3d_t GetNormalRebuilt()

Returns

tri3d_t

the triangle with the rebuilt normal

GetRewind()

Creates a new triangle with reversed vertex order and flipped normal

public readonly tri3d_t GetRewind()

Returns

tri3d_t

A new triangle with reversed vertex order

GetSegmentsFromPlaneClip(IFlat3d)

Gets the line segments resulting from intersecting this triangle with a clipping plane.

public readonly IEnumerable<Segment3d> GetSegmentsFromPlaneClip(IFlat3d clipPlane)

Parameters

clipPlane IFlat3d

The clipping plane

Returns

IEnumerable<Segment3d>

An enumerable of line segments representing the intersection

GetTransform(Mat4d)

Creates a new triangle by transforming this triangle using the specified matrix; the normal is transformed without the translation part.

public readonly tri3d_t GetTransform(Mat4d mat)

Parameters

mat Mat4d

The transformation matrix.

Returns

tri3d_t

A new transformed triangle.

GetTranslate(vec3d_t)

Creates a new triangle by translating this triangle by the specified vector.

public readonly tri3d_t GetTranslate(vec3d_t v)

Parameters

v vec3d_t

The translation vector.

Returns

tri3d_t

A new translated triangle.

GetTriSplition(double[], out tri3d_t[], out tri3d_t[])

Get triangles splition by pointWeights interpolation. negativeTris or positiveTris are null if no triangles generated. If all pointWeights is 0, no triangle generated.

public readonly void GetTriSplition(double[] pointWeights, out tri3d_t[] positiveTris, out tri3d_t[] negativeTris)

Parameters

pointWeights double[]

weights of points

positiveTris tri3d_t[]

triangles with positive or zero weight

negativeTris tri3d_t[]

triangles with negative or zero weight

ReadBin(BinaryReader)

Reads a triangle written by WriteBin(BinaryWriter): p0, p1, p2, n.

public static tri3d_t ReadBin(BinaryReader reader)

Parameters

reader BinaryReader

The binary reader to read from

Returns

tri3d_t

the triangle

ToString()

Returns the fully qualified type name of this instance.

public override readonly string ToString()

Returns

string

The fully qualified type name.

WriteBin(BinaryWriter)

Writes the object's data to a binary stream.

public readonly void WriteBin(BinaryWriter writer)

Parameters

writer BinaryWriter

The binary writer to write to

Operators

operator ==(tri3d_t, tri3d_t)

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

Parameters

left tri3d_t
right tri3d_t

Returns

bool

operator !=(tri3d_t, tri3d_t)

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

Parameters

left tri3d_t
right tri3d_t

Returns

bool