C# Класс GeometryClassLibrary.Matrix

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
AbsoluteValue ( ) : Matrix

Returns a matrix that is this matrix with the absolute value function applied to each element

AddTo ( Matrix passedMatrix ) : Matrix

Returns the sum of this matrix and the passed matrix

AddToAt ( int row, int col, Matrix matrix ) : void

Adds the passed matrix to the larger matrix starting at the specified row,col entry.

As1DArray ( EnumerationOrder order = EnumerationOrder.ByRow ) : double[]
CanBeAddedTo ( Matrix passedMatrix ) : bool

Checks to see if this matrix and the passed matrix can be added together. In order to be able to add two matrices, they must have the same Distances.

CanBeMultipliedBy ( Matrix passedMatrix ) : bool

Checks to see if this matrix can be multiplied by the passed matrix IN THAT ORDER. In order to multiply two matrices, the number of columns in the first matrix must equal the number of rows in the second matrix.

Columns ( ) : List
ConvertRotationMatrixToQuaternion ( ) : Matrix

Converts the given rotation Matrix into a Quaternion, which also represents orientation but in a more mathematically unique way since only two quaternions represent the same orientation, and they have the following relation to each other: q = -q

Decompose ( int &permutationArray, int &toggle ) : Matrix

Performs Doolittle decomposition with partial pivoting and returns a combined LU matrix

Determinant ( ) : double

Computes the determinant of a matrix

Equals ( object obj ) : bool

Does the same thing as == if the passed-in object is an identical matrix

EulerAngles ( ) : List

Returns the euler angles (for rotations in x, y,z order) assuming the upper left 3x3 submatrix is a rotation matrix.

ExtractLower ( ) : Matrix

Returns Matrix with only the values in the lower triangle (below main diagonal) intact. Puts 1.0's on diagonal and 0.0's in upper triangle

ExtractUpper ( ) : Matrix

Returns Matrix with only the values in the main diagonal and upper triangle (above main diagonal) intact. Has 0.0's in lower triangle

GenerateCofactorMatrix ( ) : Matrix

Creates the cofactor matrix corresponding to this matrix

GetCofactor ( int rowIndex, int columnIndex ) : double

Returns the cofactor for the specified element of a square matrix

GetColumn ( int passedColumnIndex ) : double[]

Returns the specified column of the matrix

GetElement ( int rowIndex, int columnIndex ) : double

Returns the element at row "rowIndex" and column "columnIndex"

GetHashCode ( ) : int
GetPseudoInverse ( double a ) : ].double[
GetRow ( int passedrowIndex ) : double[]

Returns the specified row of the matrix

GetSubMatrix ( int indexOfRowToLeaveOut, int indexOfColumnToLeaveOut ) : Matrix

Returns a matrix with the specified row and column removed

IdentityMatrix ( int passedNumberOfRowsAndColumns ) : Matrix

Returns an Identity Matrix of the specified size. That is, a square matrix with 1's on the diagonal and 0's everywhere else.

InsertMatrixAt ( Matrix passedMatrix, int destinationRow, int destinationColumn ) : Matrix

Inserts the passed Matrix into this Matrix starting at the specified index

Invert ( ) : Matrix

Returns the inverse of this matrix

IsAllZeros ( ) : bool

Returns true if every element in this matrix is zero, false otherwise

IsInvertible ( ) : bool

Returns true if this matrix has an inverse, false otherwise

IsSquare ( ) : bool

Checks to see if this matrix is square

LUDecomp ( double a, double &lower, double &upper ) : void
LUSolve ( double l, double u, double b ) : double[]
Matrix ( Matrix passedMatrix ) : System

Makes a copy of the passed matrix

Matrix ( double array ) : System

Creates a matrix with a single column from the array.

Matrix ( double array, int numRows, int numCols, EnumerationOrder order = EnumerationOrder.ByColumn ) : System

Construct a matrix from a 1 Dimensional array either building row by row, or column by column.

Matrix ( int numRowsAndColumns ) : System

Creates a square matrix with the passed number of rows and columns

Matrix ( int numRows, int numCols ) : System

Creates a matrix of the desired number of rows and columns, with all entries initialized to zero.

MultiplyBy ( Matrix passedMatrix ) : Matrix

Returns the product matrix of this matrix multiplied by the passed matrix, in that order.

NullSpace ( ) : List
PointAsProjectiveColumnVector ( Point point ) : Matrix
ProjectiveMatrixToRotationMatrix ( Matrix matrix ) : Matrix
PseudoInvSolve ( double p, double b ) : double[]
RemoveColumn ( int columnIndexToDelete ) : Matrix

Returns a matrix with the specified column removed

RemoveColumns ( int passedIndicesOfColumnsToRemove ) : Matrix

Returns a new matrix with all of the specified columns removed

RemoveRow ( int rowIndexToDelete ) : Matrix

Returns a matrix with the specified row removed

RemoveRows ( int passedIndicesOfRowsToRemove ) : Matrix

Returns a new matrix with all of the specified rows removed

RotationMatrixAboutOrigin ( Rotation passedRotation ) : Matrix

Returns a matrix that can be multiplied by another matrix to represent a rotation of that matrix about the passed axis line by the specified angle

RotationMatrixAboutX ( System.Angle rotationAngle ) : Matrix

Returns a matrix that can be multiplied by another matrix to represent a rotation of that matrix about the X axis by the specified angle

RotationMatrixAboutY ( System.Angle rotationAngle ) : Matrix

Returns a matrix that can be multiplied by another matrix to represent a rotation of that matrix about the Y axis by the specified angle

RotationMatrixAboutZ ( System.Angle rotationAngle ) : Matrix

Returns a matrix that can be multiplied by another matrix to represent a rotation of that matrix about the Z axis by the specified angle

Rows ( ) : List
SetColumn ( int passedColumnIndex, double passedColumn ) : void

Replaces the specified column of the matrix with the passed column

SetElement ( int rowIndex, int columnIndex, double element ) : void

SetRow ( int passedrowIndex, double passedRow ) : void

Replaces the specified row of the matrix with the passed row

ShiftPoint ( Point point, Matrix matrix ) : Point
SolveMatrix ( double augmentedMatrix ) : double[]

Turns an augmented matrix into Reduced Row Echelon form, by modifying the matrix in place. Then returns the last column.

SystemSolve ( Matrix columnMatrix ) : Matrix

Solves for the column matrix x, where Ax = b.

ToString ( ) : string
Transpose ( ) : Matrix

Returns the transpose of a given matrix. The transpose is found by swapping the rows and columns (i.e. reflecting all the elements across the main diagonal)

operator ( ) : Matrix

Returns the sum of 2 matrices of equal size

operator ( ) : bool

Not a perfect equality operator, is only accurate up to difference of 0.00000001 in any two elements

this ( int i ) : double

For setting and accessing column vectors

this ( int i, int j ) : double

Приватные методы

Метод Описание
Matrix ( ) : System

Private constructor for the benefit of data frameworks like Entity Framework and Json.NET

Matrix ( Matrix passedMatrix ) : System

Makes a copy of the passed matrix

_enumerateByColumn ( ) : double[]
_enumerateByRow ( ) : double[]
_pointFromProjectiveColumnVector ( Matrix projectiveVector ) : Point
_vectorOfDoublesToVectorOfInches ( Vector vector ) : Vector

Описание методов

AbsoluteValue() публичный Метод

Returns a matrix that is this matrix with the absolute value function applied to each element
public AbsoluteValue ( ) : Matrix
Результат Matrix

AddTo() публичный Метод

Returns the sum of this matrix and the passed matrix
public AddTo ( Matrix passedMatrix ) : Matrix
passedMatrix Matrix
Результат Matrix

AddToAt() публичный Метод

Adds the passed matrix to the larger matrix starting at the specified row,col entry.
public AddToAt ( int row, int col, Matrix matrix ) : void
row int
col int
matrix Matrix
Результат void

As1DArray() публичный Метод

public As1DArray ( EnumerationOrder order = EnumerationOrder.ByRow ) : double[]
order EnumerationOrder
Результат double[]

CanBeAddedTo() публичный Метод

Checks to see if this matrix and the passed matrix can be added together. In order to be able to add two matrices, they must have the same Distances.
public CanBeAddedTo ( Matrix passedMatrix ) : bool
passedMatrix Matrix
Результат bool

CanBeMultipliedBy() публичный Метод

Checks to see if this matrix can be multiplied by the passed matrix IN THAT ORDER. In order to multiply two matrices, the number of columns in the first matrix must equal the number of rows in the second matrix.
public CanBeMultipliedBy ( Matrix passedMatrix ) : bool
passedMatrix Matrix
Результат bool

Columns() публичный Метод

public Columns ( ) : List
Результат List

ConvertRotationMatrixToQuaternion() публичный Метод

Converts the given rotation Matrix into a Quaternion, which also represents orientation but in a more mathematically unique way since only two quaternions represent the same orientation, and they have the following relation to each other: q = -q
public ConvertRotationMatrixToQuaternion ( ) : Matrix
Результат Matrix

Decompose() публичный Метод

Performs Doolittle decomposition with partial pivoting and returns a combined LU matrix
public Decompose ( int &permutationArray, int &toggle ) : Matrix
permutationArray int Keeps track of how the matrices have been rearranged during the calculation
toggle int is +1 or -1 (even or odd)
Результат Matrix

Determinant() публичный Метод

Computes the determinant of a matrix
public Determinant ( ) : double
Результат double

Equals() публичный Метод

Does the same thing as == if the passed-in object is an identical matrix
public Equals ( object obj ) : bool
obj object
Результат bool

EulerAngles() публичный Метод

Returns the euler angles (for rotations in x, y,z order) assuming the upper left 3x3 submatrix is a rotation matrix.
public EulerAngles ( ) : List
Результат List

ExtractLower() публичный Метод

Returns Matrix with only the values in the lower triangle (below main diagonal) intact. Puts 1.0's on diagonal and 0.0's in upper triangle
public ExtractLower ( ) : Matrix
Результат Matrix

ExtractUpper() публичный Метод

Returns Matrix with only the values in the main diagonal and upper triangle (above main diagonal) intact. Has 0.0's in lower triangle
public ExtractUpper ( ) : Matrix
Результат Matrix

GenerateCofactorMatrix() публичный Метод

Creates the cofactor matrix corresponding to this matrix
public GenerateCofactorMatrix ( ) : Matrix
Результат Matrix

GetCofactor() публичный Метод

Returns the cofactor for the specified element of a square matrix
public GetCofactor ( int rowIndex, int columnIndex ) : double
rowIndex int
columnIndex int
Результат double

GetColumn() публичный Метод

Returns the specified column of the matrix
public GetColumn ( int passedColumnIndex ) : double[]
passedColumnIndex int
Результат double[]

GetElement() публичный Метод

Returns the element at row "rowIndex" and column "columnIndex"
public GetElement ( int rowIndex, int columnIndex ) : double
rowIndex int The row number of the desired element
columnIndex int The column number of the desired element
Результат double

GetHashCode() публичный Метод

public GetHashCode ( ) : int
Результат int

GetPseudoInverse() публичный статический Метод

public static GetPseudoInverse ( double a ) : ].double[
a double
Результат ].double[

GetRow() публичный Метод

Returns the specified row of the matrix
public GetRow ( int passedrowIndex ) : double[]
passedrowIndex int
Результат double[]

GetSubMatrix() публичный Метод

Returns a matrix with the specified row and column removed
public GetSubMatrix ( int indexOfRowToLeaveOut, int indexOfColumnToLeaveOut ) : Matrix
indexOfRowToLeaveOut int
indexOfColumnToLeaveOut int
Результат Matrix

IdentityMatrix() публичный статический Метод

Returns an Identity Matrix of the specified size. That is, a square matrix with 1's on the diagonal and 0's everywhere else.
public static IdentityMatrix ( int passedNumberOfRowsAndColumns ) : Matrix
passedNumberOfRowsAndColumns int
Результат Matrix

InsertMatrixAt() публичный Метод

Inserts the passed Matrix into this Matrix starting at the specified index
public InsertMatrixAt ( Matrix passedMatrix, int destinationRow, int destinationColumn ) : Matrix
passedMatrix Matrix
destinationRow int
destinationColumn int
Результат Matrix

Invert() публичный Метод

Returns the inverse of this matrix
public Invert ( ) : Matrix
Результат Matrix

IsAllZeros() публичный Метод

Returns true if every element in this matrix is zero, false otherwise
public IsAllZeros ( ) : bool
Результат bool

IsInvertible() публичный Метод

Returns true if this matrix has an inverse, false otherwise
public IsInvertible ( ) : bool
Результат bool

IsSquare() публичный Метод

Checks to see if this matrix is square
public IsSquare ( ) : bool
Результат bool

LUDecomp() публичный статический Метод

public static LUDecomp ( double a, double &lower, double &upper ) : void
a double
lower double
upper double
Результат void

LUSolve() публичный статический Метод

public static LUSolve ( double l, double u, double b ) : double[]
l double
u double
b double
Результат double[]

Matrix() публичный Метод

Makes a copy of the passed matrix
public Matrix ( Matrix passedMatrix ) : System
passedMatrix Matrix
Результат System

Matrix() публичный Метод

Creates a matrix with a single column from the array.
public Matrix ( double array ) : System
array double
Результат System

Matrix() публичный Метод

Construct a matrix from a 1 Dimensional array either building row by row, or column by column.
public Matrix ( double array, int numRows, int numCols, EnumerationOrder order = EnumerationOrder.ByColumn ) : System
array double
numRows int
numCols int
order EnumerationOrder
Результат System

Matrix() публичный Метод

Creates a square matrix with the passed number of rows and columns
public Matrix ( int numRowsAndColumns ) : System
numRowsAndColumns int
Результат System

Matrix() публичный Метод

Creates a matrix of the desired number of rows and columns, with all entries initialized to zero.
public Matrix ( int numRows, int numCols ) : System
numRows int
numCols int
Результат System

MultiplyBy() публичный Метод

Returns the product matrix of this matrix multiplied by the passed matrix, in that order.
public MultiplyBy ( Matrix passedMatrix ) : Matrix
passedMatrix Matrix
Результат Matrix

NullSpace() публичный Метод

public NullSpace ( ) : List
Результат List

PointAsProjectiveColumnVector() публичный статический Метод

public static PointAsProjectiveColumnVector ( Point point ) : Matrix
point Point
Результат Matrix

ProjectiveMatrixToRotationMatrix() публичный статический Метод

public static ProjectiveMatrixToRotationMatrix ( Matrix matrix ) : Matrix
matrix Matrix
Результат Matrix

PseudoInvSolve() публичный статический Метод

public static PseudoInvSolve ( double p, double b ) : double[]
p double
b double
Результат double[]

RemoveColumn() публичный Метод

Returns a matrix with the specified column removed
public RemoveColumn ( int columnIndexToDelete ) : Matrix
columnIndexToDelete int
Результат Matrix

RemoveColumns() публичный Метод

Returns a new matrix with all of the specified columns removed
public RemoveColumns ( int passedIndicesOfColumnsToRemove ) : Matrix
passedIndicesOfColumnsToRemove int
Результат Matrix

RemoveRow() публичный Метод

Returns a matrix with the specified row removed
public RemoveRow ( int rowIndexToDelete ) : Matrix
rowIndexToDelete int
Результат Matrix

RemoveRows() публичный Метод

Returns a new matrix with all of the specified rows removed
public RemoveRows ( int passedIndicesOfRowsToRemove ) : Matrix
passedIndicesOfRowsToRemove int
Результат Matrix

RotationMatrixAboutOrigin() публичный статический Метод

Returns a matrix that can be multiplied by another matrix to represent a rotation of that matrix about the passed axis line by the specified angle
public static RotationMatrixAboutOrigin ( Rotation passedRotation ) : Matrix
passedRotation Rotation
Результат Matrix

RotationMatrixAboutX() публичный статический Метод

Returns a matrix that can be multiplied by another matrix to represent a rotation of that matrix about the X axis by the specified angle
public static RotationMatrixAboutX ( System.Angle rotationAngle ) : Matrix
rotationAngle System.Angle
Результат Matrix

RotationMatrixAboutY() публичный статический Метод

Returns a matrix that can be multiplied by another matrix to represent a rotation of that matrix about the Y axis by the specified angle
public static RotationMatrixAboutY ( System.Angle rotationAngle ) : Matrix
rotationAngle System.Angle
Результат Matrix

RotationMatrixAboutZ() публичный статический Метод

Returns a matrix that can be multiplied by another matrix to represent a rotation of that matrix about the Z axis by the specified angle
public static RotationMatrixAboutZ ( System.Angle rotationAngle ) : Matrix
rotationAngle System.Angle
Результат Matrix

Rows() публичный Метод

public Rows ( ) : List
Результат List

SetColumn() публичный Метод

Replaces the specified column of the matrix with the passed column
public SetColumn ( int passedColumnIndex, double passedColumn ) : void
passedColumnIndex int
passedColumn double
Результат void

SetElement() публичный Метод

public SetElement ( int rowIndex, int columnIndex, double element ) : void
rowIndex int The number of the row where the element will be added
columnIndex int The number of the column where the element will be added
element double
Результат void

SetRow() публичный Метод

Replaces the specified row of the matrix with the passed row
public SetRow ( int passedrowIndex, double passedRow ) : void
passedrowIndex int
passedRow double
Результат void

ShiftPoint() публичный статический Метод

public static ShiftPoint ( Point point, Matrix matrix ) : Point
point Point
matrix Matrix
Результат Point

SolveMatrix() публичный статический Метод

Turns an augmented matrix into Reduced Row Echelon form, by modifying the matrix in place. Then returns the last column.
public static SolveMatrix ( double augmentedMatrix ) : double[]
augmentedMatrix double
Результат double[]

SystemSolve() публичный Метод

Solves for the column matrix x, where Ax = b.
public SystemSolve ( Matrix columnMatrix ) : Matrix
columnMatrix Matrix
Результат Matrix

ToString() публичный Метод

public ToString ( ) : string
Результат string

Transpose() публичный Метод

Returns the transpose of a given matrix. The transpose is found by swapping the rows and columns (i.e. reflecting all the elements across the main diagonal)
public Transpose ( ) : Matrix
Результат Matrix

operator() публичный статический Метод

Returns the sum of 2 matrices of equal size
public static operator ( ) : Matrix
Результат Matrix

operator() публичный статический Метод

Not a perfect equality operator, is only accurate up to difference of 0.00000001 in any two elements
public static operator ( ) : bool
Результат bool

this() публичный Метод

For setting and accessing column vectors
public this ( int i ) : double
i int
Результат double

this() публичный Метод

public this ( int i, int j ) : double
i int
j int
Результат double