Skip to content

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

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open

Matrix Library #448

wants to merge 4 commits into from

Conversation

jnyfah
Copy link
Collaborator

@jnyfah jnyfah commented May 3, 2025

This PR introduces the support of Mathematics Matrices.

This helps for our effort to move away of GLM library

@jnyfah jnyfah changed the title Matrix Matrix Library May 3, 2025
@jnyfah jnyfah requested a review from JeanPhilippeKernel May 3, 2025 12:39
@jnyfah jnyfah marked this pull request as ready for review May 3, 2025 12:39
@jnyfah jnyfah enabled auto-merge (squash) May 3, 2025 12:40
@JeanPhilippeKernel JeanPhilippeKernel added Feature request New feature area-window Work on Window system area-macOS Work on macOS system labels May 3, 2025
@JeanPhilippeKernel JeanPhilippeKernel added this to the Born baby (0.2.0) milestone May 3, 2025
@JeanPhilippeKernel JeanPhilippeKernel moved this to In Progress in ZEngine Board May 3, 2025
Comment on lines +11 to +26
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];
}
};

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 ?

Copy link
Collaborator Author

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

Comment on lines +40 to +60
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;
}

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>()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
inline Mat2f identity<Mat2f>()
inline Mat2f Identity<Mat2f>()

}

template <>
inline Mat3f identity<Mat3f>()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
inline Mat3f identity<Mat3f>()
inline Mat3f Identity<Mat3f>()

}

template <>
inline Mat4f identity<Mat4f>()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
inline Mat4f identity<Mat4f>()
inline Mat4f Identity<Mat4f>()

return *this;
}

Mat3 inverse()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Mat3 inverse()
Mat3 Inverse()

Comment on lines +321 to +322
for (size_t i = 0; i < 16; ++i)
this->m_data[i] = 0;

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)

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-macOS Work on macOS system area-window Work on Window system Feature request New feature
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants