Class Tri3d
Basic 3D Triangle.
public class Tri3d : ITri3d, IFlat3d, IExpandToBox3d, IEquatable<Tri3d>, IBinaryIo, IWriteBin
- Inheritance
-
Tri3d
- Implements
- Inherited Members
- Extension Methods
Constructors
Tri3d(ITri3d)
Creates a triangle from an ITri3d interface
public Tri3d(ITri3d t)
Parameters
t
ITri3dThe source triangle implementing ITri3d
Tri3d(ITri3d, Mat4d)
Creates a triangle from an ITri3d interface and transforms it using a matrix
public Tri3d(ITri3d t, Mat4d mat)
Parameters
Tri3d(Tri3d, bool)
Creates a triangle by copying or referencing another triangle
public Tri3d(Tri3d t, bool useRef = false)
Parameters
t
Tri3dThe source triangle
useRef
boolIf true, references to the source triangle's vertices and normal are used; otherwise, copies are created
Tri3d(Vec3d, Vec3d, Vec3d)
Ctor.
public Tri3d(Vec3d p0, Vec3d p1, Vec3d p2)
Parameters
Tri3d(Vec3d, Vec3d, Vec3d, Vec3d)
Creates a triangle with the specified vertices and normal vector
public Tri3d(Vec3d p0, Vec3d p1, Vec3d p2, Vec3d n)
Parameters
Tri3d(tri3d)
Ctor.
public Tri3d(tri3d src)
Parameters
src
tri3dsrc
Tri3d(bool)
Ctor.
public Tri3d(bool initAllMemberToNull = false)
Parameters
initAllMemberToNull
boolIf true, the three apexes and normal are null; otherwise, they are initialized by the default constructor of Vec3d.
Tri3d(BinaryReader)
Creates a triangle by reading its data from a binary reader
public Tri3d(BinaryReader reader)
Parameters
reader
BinaryReaderThe binary reader to read from
Fields
n
normal vector of this triangle.
public Vec3d n
Field Value
ps
Points. Three apexs.
public Vec3d[] ps
Field Value
- Vec3d[]
Properties
Area
Gets the area of the triangle
public double Area { get; }
Property Value
NativeByteSize
Native byte size.
public static int NativeByteSize { get; }
Property Value
Methods
Equals(Tri3d)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(Tri3d other)
Parameters
other
Tri3dAn object to compare with this object.
Returns
Equals(object)
Determines whether the specified object is equal to the current object.
public override bool Equals(object obj)
Parameters
obj
objectThe object to compare with the current object.
Returns
ExpandToBox3d(Box3d)
Expands the destination box. This function is usually used to compute the bounding box of elements.
public void ExpandToBox3d(Box3d dst)
Parameters
dst
Box3dDestination box
GetApex(int)
Gets the specified vertex (apex) of this triangle.
public Vec3d GetApex(int i)
Parameters
i
intIndex of the vertex (0-2)
Returns
- Vec3d
The position of the specified vertex
GetEdgeArrow(int)
Gets the edge vector from vertex i to vertex i+1.
public Vec3d GetEdgeArrow(int i)
Parameters
i
intThe index of the starting vertex (0, 1, or 2).
Returns
- Vec3d
The vector representing the edge.
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
GetLocate()
Gets an anchor point on this flat surface.
public Vec3d GetLocate()
Returns
- Vec3d
A point on the flat surface
GetNormal()
Gets the normal vector of the flat surface.
public Vec3d GetNormal()
Returns
- Vec3d
The unit normal vector
GetRewind()
Creates a new triangle with reversed vertex order and flipped normal
public Tri3d GetRewind()
Returns
- Tri3d
A new triangle with reversed vertex order
GetTransform(Mat4d)
Creates a new triangle by transforming this triangle using the specified matrix.
public Tri3d GetTransform(Mat4d mat)
Parameters
mat
Mat4dThe transformation matrix.
Returns
- Tri3d
A new transformed triangle.
GetTranslate(Vec3d)
Creates a new triangle by translating this triangle by the specified vector.
public Tri3d GetTranslate(Vec3d v)
Parameters
v
Vec3dThe translation vector.
Returns
- Tri3d
A new translated triangle.
GetTriSplition(double[], out Tri3d[], out Tri3d[])
Get triangles splition by pointWeights
interpolation.
negativeTris
or positiveTris
are null if no triangles generated.
If all pointWeights
is 0, no triangle generated.
public void GetTriSplition(double[] pointWeights, out Tri3d[] positiveTris, out Tri3d[] negativeTris)
Parameters
pointWeights
double[]weights of points
positiveTris
Tri3d[]triangles with positive or zero weight
negativeTris
Tri3d[]triangles with negative or zero weight
ReBuildNormal()
Rebuilds the normal vector of the triangle based on its vertices.
public Vec3d ReBuildNormal()
Returns
- Vec3d
The rebuilt normal vector.
ReadBin(BinaryReader)
Reads binary data to initialize the object.
public void ReadBin(BinaryReader reader)
Parameters
reader
BinaryReaderThe binary reader to read from
Rewind()
Reverses the order of the triangle's vertices, which flips the normal direction
public void Rewind()
Rotate(Vec3d, double)
Rotates the triangle around the specified axis by the given angle.
public Tri3d Rotate(Vec3d axis, double rad)
Parameters
Returns
- Tri3d
This triangle after rotation.
Set(ITri3d)
Sets this triangle's vertices and normal from an ITri3d interface
public Tri3d Set(ITri3d t)
Parameters
t
ITri3dThe source triangle implementing ITri3d
Returns
- Tri3d
This triangle instance
Set(ITri3d, Mat4d)
Sets this triangle's vertices and normal from an ITri3d interface and transforms them using a matrix
public Tri3d Set(ITri3d t, Mat4d mat)
Parameters
Returns
- Tri3d
This triangle instance
Set(Tri3d, bool)
Sets this triangle's vertices and normal from another triangle
public Tri3d Set(Tri3d t, bool useRef = false)
Parameters
t
Tri3dThe source triangle
useRef
boolIf true, references to the source triangle's vertices and normal are used; otherwise, copies are created
Returns
- Tri3d
This triangle instance
Set(Vec3d, Vec3d, Vec3d)
Set value.
public Tri3d Set(Vec3d p0, Vec3d p1, Vec3d p2)
Parameters
Returns
- Tri3d
this
Set(Vec3d, Vec3d, Vec3d, Vec3d)
Sets the triangle's vertices and normal vector
public Tri3d Set(Vec3d p0, Vec3d p1, Vec3d p2, Vec3d n)
Parameters
Returns
- Tri3d
This triangle instance
SetOrderForward(int)
Reorders the triangle's vertices to make the specified vertex the first one
public void SetOrderForward(int index)
Parameters
index
intThe index of the vertex to make first (0, 1, or 2)
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
Transform(Mat4d)
Transforms the triangle using the specified transformation matrix.
public Tri3d Transform(Mat4d mat)
Parameters
mat
Mat4dThe transformation matrix.
Returns
- Tri3d
This triangle after transformation.
Translate(Vec3d)
Translates the triangle by the specified vector.
public Tri3d Translate(Vec3d v)
Parameters
v
Vec3dThe translation vector.
Returns
- Tri3d
This triangle after translation.
Translate(double, double, double)
Translates the triangle by the specified x, y, and z coordinates.
public Tri3d Translate(double x, double y, double z)
Parameters
x
doubleThe x-coordinate of the translation.
y
doubleThe y-coordinate of the translation.
z
doubleThe z-coordinate of the translation.
Returns
- Tri3d
This triangle after translation.
WriteBin(BinaryWriter)
Writes the object's data to a binary stream.
public void WriteBin(BinaryWriter writer)
Parameters
writer
BinaryWriterThe binary writer to write to