Skip to content
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

Open
wants to merge 4 commits into
base: usage-examples
Choose a base branch
from

Conversation

ShaunR1991
Copy link

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:

  • C++ Code
  • C# Code (Top-Level and Object-Oriented versions)
  • Python Code
  • Text Description File
  • Image of Output (if applicable)

No resource zip files are required for these examples.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (update or new)

How Has This Been Tested?

All functions were run and tested to ensure output was as expected.

Testing Checklist

  • Tested in latest Chrome
  • Tested in latest Firefox
  • npm run build
  • npm run preview

Checklist

If involving code

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

If modified config files

  • I have checked the following files for changes:
    • package.json
    • astro.config.mjs
    • netlify.toml
    • docker-compose.yml
    • custom.css

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.

Copy link

netlify bot commented Nov 23, 2024

Deploy Preview for splashkit-usage-examples ready!

Name Link
🔨 Latest commit 7369038
🔍 Latest deploy log https://app.netlify.com/sites/splashkit-usage-examples/deploys/6745840b166bd500086d4674
😎 Deploy Preview https://deploy-preview-285--splashkit-usage-examples.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

@breezy-codes breezy-codes left a 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;

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

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

Copy link

@SimonRhook SimonRhook left a 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);

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

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

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

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

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

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

Choose a reason for hiding this comment

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

These next few lines are missing information comments that exist in the other files
image

ClearScreen(ColorWhite());

// Define the scaling factors
Point2D matrixScale = new Point2D() { X = 1.5, Y = 1.2 };

Choose a reason for hiding this comment

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

OOP and Top level variants are missing the informational comments for the scaling factors
image

double translation_y = 100;

// Create a translation matrix using the translation values
matrix_2d my_matrix_1 = translation_matrix(translation_x, translation_y);

Choose a reason for hiding this comment

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

this matrix variable has a different name in cpp than it does in all other files. I would recommend updating the other files as their variable names are the same as the function called, which can potentially cause confusion
image

@@ -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.

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

@ShaunR1991
Copy link
Author

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

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.

@ShaunR1991
Copy link
Author

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/

Thanks for the feedback. Code has been adjusted accordingly.

Copy link

@SimonRhook SimonRhook left a 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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants