-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add Matrix Operations Physics Usage Examples #285
base: usage-examples
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for splashkit-usage-examples ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
The OOP code will need to be changed for all files to match in with how OOP is done for programs on splashkit.
The guide on how OOP is meant to be done is found here -
https://thoth-tech.netlify.app/products/splashkit/splashkit-website/tutorials-documentation/04-oop-styling/
@@ -0,0 +1,52 @@ | |||
using static SplashKitSDK.SplashKit; |
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.
For OOP usage examples are done with just using SplashKitSDK;
Meaning each splashkit function would use SplashKit.
public static void Main() | ||
{ | ||
// Open the window | ||
OpenWindow("Apply Matrix", 400, 400); |
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.
So here this would be SplashKit.OpenWindow
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've reviewed this request and have found a few issues, there are some comment inconsistencies throughout the file, the OOP needs to be updated as mentioned in another comment. There are some .txt files that have been mixed up and a top level code seems to be missing. I have left comments in the code as pointers for updates.
Other than these small issues the code runs consistently and error free, the website builds and runs fine so once these changes are made I can approve this PR
{ | ||
public static void Main() | ||
{ | ||
OpenWindow("Matrix Inverse", 400, 300); |
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.
This line and line 38 seem unnecessary and do not exist in the other files
Point2D recoveredPoint = MatrixMultiply(inverseMatrix, transformedPoint); | ||
WriteLine($"Recovered Point: {PointToString(recoveredPoint)}"); | ||
|
||
CloseAllWindows(); |
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.
This line doesnt need to be here
# Multiply the two matrices | ||
result_matrix = matrix_multiply_matrix(my_matrix_1, my_matrix_2) | ||
|
||
# Print the matrices and 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.
This comment is slightly different from the other files
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.
The text files for the three matrix multiply variants are mixed up. Matrix vectors is in matrix, matrix is in points and points is in vectors
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.
This file is different code from the other files
// Create a scaling matrix using the scale factors | ||
matrix_2d scaling_matrix = scale_matrix(matrix_scale); | ||
|
||
// Print the scaling matrix |
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.
this comment is different from other files. should be "Print the scaling matrix to the console" for consistency
# Define the original triangle points (centered and larger) | ||
original_triangle = Triangle() | ||
original_triangle.points[0] = Point2D() | ||
original_triangle.points[0].x = 200 |
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.
ClearScreen(ColorWhite()); | ||
|
||
// Define the scaling factors | ||
Point2D matrixScale = new Point2D() { X = 1.5, Y = 1.2 }; |
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.
double translation_y = 100; | ||
|
||
// Create a translation matrix using the translation values | ||
matrix_2d my_matrix_1 = translation_matrix(translation_x, translation_y); |
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.
@@ -0,0 +1,5 @@ | |||
#### Translate 2D Points by Specified Coordinates | |||
|
|||
Create a translationa matrix that can be used to translate 2d points, moving them by along the x and y axes by the values provided. |
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.
very minor typo here in translational
Thanks for the feedback and thorough review. I've gone through and made the adjustments to the code. Should be in line with your review now. |
Thanks for the feedback. Code has been adjusted accordingly. |
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.
With the changes made being in line with my recommendations I can now approve this PR
- All required files are present.
- Title and explanation (.txt)
- C++ code
- C# code (top-level statements)
- C# code (Object-Oriented Programming)
- Python code
- Code correctly uses Splashkit functions.
- Code clearly demonstrates the function.
- All versions maintain the same structure and comments.
- C++ code ran correctly.
- C# top level code ran correctly.
- C# OOP code ran correctly.
- Python code ran correctly.
Description
This pull request adds simple usage examples for the following matrix manipulation functions in SplashKit:
apply_matrix_to_quad
apply_matrix_to_triangle
identity_matrix
matrix_inverse
matrix_multiply_matrix
matrix_multiply_point
matrix_multiply_vector
matrix_to_string
rotation_matrix
scale_matrix
scale_matrix_from_point
scale_matrix_from_vector
scale_rotate_translate_matrix
translation_matrix
translation_matrix_from_vector
translation_matrix_to_point
The purpose of this update is to help users understand the functionality of these matrix manipulation functions in SplashKit by providing detailed examples across supported languages (C++, C#, and Python).
Each example includes:
No resource zip files are required for these examples.
Type of change
How Has This Been Tested?
All functions were run and tested to ensure output was as expected.
Testing Checklist
npm run build
npm run preview
Checklist
If involving code
If modified config files
Additional Notes
Each example is designed to demonstrate only the basic functionality of matrix manipulation functions in SplashKit. The resources provided will enable users to replicate, modify, and understand how to implement the functions and what the expected outputs might look like.