-
Notifications
You must be signed in to change notification settings - Fork 0
Transformations #43
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
Merged
Merged
Transformations #43
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0669f5d
fix:cleanup cmake
Sophomore42 73c4ad4
feat: add module logos
Sophomore42 4affdee
feat:link logos to SDL_TEST
Sophomore42 b087841
feat:add class Mat
Sophomore42 ac5beb5
feat: using logos to calculate camera transformation
Sophomore42 59ecd29
feat: Add function Scale
Sophomore42 edea6c4
fix:using butter rotation
Sophomore42 404fbc6
fix: mark transformation finished
Sophomore42 a4feca0
fix: remove unused camera uniform
Sophomore42 fc0a774
fix: export template
Sophomore42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| cmake_minimum_required(VERSION 3.30) | ||
| project(logos LANGUAGES CXX) | ||
|
|
||
| set(CMAKE_CXX_STANDARD 23) | ||
| add_library(logos STATIC) | ||
|
|
||
| target_sources(logos | ||
| PUBLIC | ||
| FILE_SET cxx_modules TYPE CXX_MODULES FILES | ||
| modules/logos.ixx | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| // logos.ixx | ||
| // Created by wsqsy on 11/26/2025. | ||
| // | ||
| module; | ||
| #include <array> | ||
| #include <cmath> | ||
| #include <cstdint> | ||
| export module logos; | ||
|
|
||
| namespace sopho | ||
| { | ||
| export template <typename TScalar, std::uint8_t Row, std::uint8_t Col> | ||
| class Mat | ||
| { | ||
| std::array<std::array<TScalar, Col>, Row> m_data{}; | ||
|
|
||
| public: | ||
| TScalar& operator()(std::uint8_t row, std::uint8_t col) { return m_data[row][col]; } | ||
| const TScalar& operator()(std::uint8_t row, std::uint8_t col) const { return m_data[row][col]; } | ||
| TScalar& operator()(std::uint8_t row) | ||
| requires(Col == 1) | ||
| { | ||
| return m_data[row][0]; | ||
| } | ||
| TScalar* data() { return m_data[0].data(); } | ||
| template <std::uint8_t OtherCol> | ||
| Mat<TScalar, Row, OtherCol> operator*(const Mat<TScalar, Col, OtherCol>& rhs) const | ||
| { | ||
| Mat<TScalar, Row, OtherCol> result{}; | ||
|
|
||
| for (std::uint8_t r = 0; r < Row; ++r) | ||
| { | ||
| for (std::uint8_t c = 0; c < OtherCol; ++c) | ||
| { | ||
| TScalar sum{}; | ||
| for (std::uint8_t k = 0; k < Col; ++k) | ||
| { | ||
| sum += (*this)(r, k) * rhs(k, c); | ||
| } | ||
| result(r, c) = sum; | ||
| } | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
| }; | ||
|
|
||
| export Mat<float, 4, 4> MakeRotationY(float yaw) | ||
| { | ||
| float cy = std::cos(yaw); | ||
| float sy = std::sin(yaw); | ||
|
|
||
| Mat<float, 4, 4> R{}; | ||
|
|
||
| R(0, 0) = cy; | ||
| R(0, 1) = 0; | ||
| R(0, 2) = sy; | ||
| R(0, 3) = 0; | ||
| R(1, 0) = 0; | ||
| R(1, 1) = 1; | ||
| R(1, 2) = 0; | ||
| R(1, 3) = 0; | ||
| R(2, 0) = -sy; | ||
| R(2, 1) = 0; | ||
| R(2, 2) = cy; | ||
| R(2, 3) = 0; | ||
| R(3, 0) = 0; | ||
| R(3, 1) = 0; | ||
| R(3, 2) = 0; | ||
| R(3, 3) = 1; | ||
|
|
||
| return R; | ||
| } | ||
|
|
||
| export Mat<float, 4, 4> MakeRotationX(float pitch) | ||
| { | ||
| float cp = std::cos(pitch); | ||
| float sp = std::sin(pitch); | ||
|
|
||
| Mat<float, 4, 4> R{}; | ||
|
|
||
| R(0, 0) = 1; | ||
| R(0, 1) = 0; | ||
| R(0, 2) = 0; | ||
| R(0, 3) = 0; | ||
| R(1, 0) = 0; | ||
| R(1, 1) = cp; | ||
| R(1, 2) = sp; | ||
| R(1, 3) = 0; | ||
| R(2, 0) = 0; | ||
| R(2, 1) = -sp; | ||
| R(2, 2) = cp; | ||
| R(2, 3) = 0; | ||
| R(3, 0) = 0; | ||
| R(3, 1) = 0; | ||
| R(3, 2) = 0; | ||
| R(3, 3) = 1; | ||
|
|
||
| return R; | ||
| } | ||
|
|
||
| export Mat<float, 4, 4> Scale(float scale_size) | ||
| { | ||
|
|
||
| Mat<float, 4, 4> R{}; | ||
|
|
||
| R(0, 0) = scale_size; | ||
| R(0, 1) = 0; | ||
| R(0, 2) = 0; | ||
| R(0, 3) = 0; | ||
| R(1, 0) = 0; | ||
| R(1, 1) = scale_size; | ||
| R(1, 2) = 0; | ||
| R(1, 3) = 0; | ||
| R(2, 0) = 0; | ||
| R(2, 1) = 0; | ||
| R(2, 2) = scale_size; | ||
| R(2, 3) = 0; | ||
| R(3, 0) = 0; | ||
| R(3, 1) = 0; | ||
| R(3, 2) = 0; | ||
| R(3, 3) = 1; | ||
|
|
||
| return R; | ||
| } | ||
|
|
||
| } // namespace sopho |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.