-
-
Notifications
You must be signed in to change notification settings - Fork 23
Matrix Library #448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Matrix Library #448
Conversation
struct RowProxy | ||
{ | ||
T* row_data; | ||
|
||
T& operator[](size_t col) | ||
{ | ||
ZENGINE_VALIDATE_ASSERT(col < C, "Column index out of range"); | ||
return row_data[col]; | ||
} | ||
|
||
const T& operator[](size_t col) const | ||
{ | ||
ZENGINE_VALIDATE_ASSERT(col < C, "Column index out of range"); | ||
return row_data[col]; | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just thought it would be cool if someone just needed a row or column from a matrix 😂, but i can take it out if it is not necessary
Vec<T, C> getRow(size_t row) const | ||
{ | ||
ZENGINE_VALIDATE_ASSERT(row < R, "Row index out of range"); | ||
Vec<T, C> result; | ||
for (size_t i = 0; i < C; ++i) | ||
{ | ||
result[i] = this->m_data[row * C + i]; | ||
} | ||
return result; | ||
} | ||
|
||
Vec<T, R> getColumn(size_t col) const | ||
{ | ||
ZENGINE_VALIDATE_ASSERT(col < C, "Column index out of range"); | ||
Vec<T, R> result; | ||
for (size_t i = 0; i < R; ++i) | ||
{ | ||
result[i] = this->m_data[i * C + col]; | ||
} | ||
return result; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this ?
T identity(); | ||
|
||
template <> | ||
inline Mat2f identity<Mat2f>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inline Mat2f identity<Mat2f>() | |
inline Mat2f Identity<Mat2f>() |
} | ||
|
||
template <> | ||
inline Mat3f identity<Mat3f>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inline Mat3f identity<Mat3f>() | |
inline Mat3f Identity<Mat3f>() |
} | ||
|
||
template <> | ||
inline Mat4f identity<Mat4f>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inline Mat4f identity<Mat4f>() | |
inline Mat4f Identity<Mat4f>() |
return *this; | ||
} | ||
|
||
Mat3 inverse() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mat3 inverse() | |
Mat3 Inverse() |
for (size_t i = 0; i < 16; ++i) | ||
this->m_data[i] = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can simply zero it by memset(....)
Matrix<T, R, C> operator+(Matrix<T, R, C>& other) | ||
{ | ||
Matrix<T, R, C> result{}; | ||
for (size_t i = 0; i < R; ++i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the matrix manipulation Column major
This PR introduces the support of Mathematics Matrices.
This helps for our effort to move away of GLM library