C# Class tools.Math3DHelper

A helper class that encapsulates common operations NOT provided by the XNA framework.
Show file Open project: denniskb/asvo_cuda

Public Methods

Method Description
export ( Matrix matrix, BinaryWriter writer ) : void

Writes the contents of the Matrix to a binary stream using the provided BinaryWriter. Output-format: bytes: type/format: interpretation: =========================================== 4 IEEE 32 bit float first row, first column 4 IEEE 32 bit float first row, second column 4 IEEE 32 bit float first row, third column 4 IEEE 32 bit float first row, fourth column (repeat for second, third and fourth row)

export ( Vector2 vector, BinaryWriter writer ) : void

Writes the contents of the Vector2 to a binary stream using the provided BinaryWriter. Output-format: bytes: type/format: interpretation: =========================================== 4 IEEE 32 bit float first coordiante 4 IEEE 32 bit float second coordinate

export ( Vector3 vector, BinaryWriter writer ) : void

Writes the contents of the Vector3 to a binary stream using the provided BinaryWriter. Output-format: bytes: type/format: interpretation: =========================================== 4 IEEE 32 bit float first coordinate 4 IEEE 32 bit float second coordinate 4 IEEE 32 bit float third coordinate

export ( Vector4 vector, BinaryWriter writer ) : void

Writes the contents of the Vector4 to a binary stream using the provided BinaryWriter. Output-format: bytes: type/format: interpretation: =========================================== 4 IEEE 32 bit float first coordinate 4 IEEE 32 bit float second coordinate 4 IEEE 32 bit float third coordinate 4 IEEE 32 bit float fourth coordinate

intersects ( ushort x, ushort y, ushort z, byte level, double gridDim, Vector3 octreeMin, Vector3 v0, Vector3 v1, Vector3 v2, Vector3 triBBmin, Vector3 triBBmax ) : bool

Calling wrapper around isectboxtri. For more info see Math3DHelper.isectboxtri documentation.

mul ( Vector3 &vector, Matrix &matrix ) : void

Computes the product of a 3 dimensional vector with a 4 dimensional matrix. The Vector is expanded to (x, y, z, 1) and the result is divided by w.

round ( double d ) : int

Rounds a floating point number to the nearest integer.

Private Methods

Method Description
getmax ( DoublePoint points, DoublePoint axis ) : double

Helper function for isectboxtri.

getmin ( DoublePoint points, DoublePoint axis ) : double

Helper function for isectboxtri.

isect ( DoublePoint boxpoints, DoublePoint tripoints, DoublePoint axis ) : bool

Helper function for isectboxtri.

isectboxtri ( double centerX, double centerY, double centerZ, double boxHalfDim, Vector3 v0, Vector3 v1, Vector3 v2 ) : bool

Tests whether a triangle intersects an axis-aligned bounding box. Original code by Mike Vandelay

Method Details

export() public static method

Writes the contents of the Matrix to a binary stream using the provided BinaryWriter. Output-format: bytes: type/format: interpretation: =========================================== 4 IEEE 32 bit float first row, first column 4 IEEE 32 bit float first row, second column 4 IEEE 32 bit float first row, third column 4 IEEE 32 bit float first row, fourth column (repeat for second, third and fourth row)
public static export ( Matrix matrix, BinaryWriter writer ) : void
matrix Matrix The matrix to be written to the stream.
writer BinaryWriter The BinaryWriter used to write to the stream.
return void

export() public static method

Writes the contents of the Vector2 to a binary stream using the provided BinaryWriter. Output-format: bytes: type/format: interpretation: =========================================== 4 IEEE 32 bit float first coordiante 4 IEEE 32 bit float second coordinate
public static export ( Vector2 vector, BinaryWriter writer ) : void
vector Vector2 The Vector2 to be written to the stream.
writer BinaryWriter The BinaryWriter used to write to the stream.
return void

export() public static method

Writes the contents of the Vector3 to a binary stream using the provided BinaryWriter. Output-format: bytes: type/format: interpretation: =========================================== 4 IEEE 32 bit float first coordinate 4 IEEE 32 bit float second coordinate 4 IEEE 32 bit float third coordinate
public static export ( Vector3 vector, BinaryWriter writer ) : void
vector Vector3 The Vector3 to be written to the stream.
writer BinaryWriter The BinaryWriter used to write to the stream.
return void

export() public static method

Writes the contents of the Vector4 to a binary stream using the provided BinaryWriter. Output-format: bytes: type/format: interpretation: =========================================== 4 IEEE 32 bit float first coordinate 4 IEEE 32 bit float second coordinate 4 IEEE 32 bit float third coordinate 4 IEEE 32 bit float fourth coordinate
public static export ( Vector4 vector, BinaryWriter writer ) : void
vector Vector4 The Vector4 to be written to the stream.
writer BinaryWriter The BinaryWriter used to write to the stream.
return void

intersects() public static method

Calling wrapper around isectboxtri. For more info see Math3DHelper.isectboxtri documentation.
public static intersects ( ushort x, ushort y, ushort z, byte level, double gridDim, Vector3 octreeMin, Vector3 v0, Vector3 v1, Vector3 v2, Vector3 triBBmin, Vector3 triBBmax ) : bool
x ushort The x-index of the voxel within the virtual uniform grid /// defined by the octree.
y ushort The y-index of the voxel within the virtual uniform grid /// defined by the octree.
z ushort The z-index of the voxel within the virtual uniform grid /// defined by the octree.
level byte The level of the voxel inside the octree.
gridDim double The dimenstion of the virtual uniform grid /// defined by the octree.
octreeMin Vector3 The minimum vector of the virtual /// uniform grid defined by the octree.
v0 Vector3 First vertex of the triangle.
v1 Vector3 Second vertex of the triangle.
v2 Vector3 Third vertex of the triangle.
triBBmin Vector3 Minimum vector of the triangle's bounding box.
triBBmax Vector3 Maximum vector of the triangle's bounding box.
return bool

mul() public static method

Computes the product of a 3 dimensional vector with a 4 dimensional matrix. The Vector is expanded to (x, y, z, 1) and the result is divided by w.
public static mul ( Vector3 &vector, Matrix &matrix ) : void
vector Vector3 3 dimensional vector, will be changed to /// vector * matrix, normalized (last column of the vector equals 1)
matrix Matrix 4 dimensional matrix
return void

round() public static method

Rounds a floating point number to the nearest integer.
public static round ( double d ) : int
d double Floating point number to be rounded.
return int