Skip to content

[Math] add assertion that the direction length of a ray is > 0#1323

Merged
tdavidcl merged 3 commits intoShamrock-code:mainfrom
tdavidcl:patch-2025-10-22-13-41
Oct 23, 2025
Merged

[Math] add assertion that the direction length of a ray is > 0#1323
tdavidcl merged 3 commits intoShamrock-code:mainfrom
tdavidcl:patch-2025-10-22-13-41

Conversation

@tdavidcl
Copy link
Member

No description provided.

@tdavidcl tdavidcl changed the title [Math] add assertion that the direction lenght of a ray is > 0 [Math] add assertion that the direction length of a ray is > 0 Oct 22, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @tdavidcl, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the robustness of the Ray class by introducing a runtime assertion. This assertion validates that the direction vector used to construct a Ray object is always non-zero, which is fundamental for correct mathematical operations like normalization and inverse direction calculations, thereby preventing potential errors and improving the stability of the math library.

Highlights

  • Ray Constructor Validation: An assertion has been added to the Ray constructor to ensure that the provided direction vector has a length greater than zero. This prevents potential issues with normalization and inverse direction calculations if a zero-length vector were passed.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds an assertion to the Ray constructor to ensure the direction vector has a non-zero length. This is a good addition to prevent division-by-zero errors. However, a division-by-zero can still occur in the member initializer list before the assertion is checked. I've added a comment with a suggestion to refactor the constructor to make it safer.

@github-actions
Copy link
Contributor

Workflow report

workflow report corresponding to commit d2e96b9
Commiter email is timothee.davidcleris@proton.me
GitHub page artifact URL GitHub page artifact link (can expire)

Pre-commit check report

Pre-commit check: ✅

trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check for merge conflicts................................................Passed
check that executables have shebangs.....................................Passed
check that scripts with shebangs are executable..........................Passed
check for added large files..............................................Passed
check for case conflicts.................................................Passed
check for broken symlinks................................................Passed
check yaml...............................................................Passed
detect private key.......................................................Passed
No-tabs checker..........................................................Passed
Tabs remover.............................................................Passed
Validate GitHub Workflows................................................Passed
clang-format.............................................................Passed
black....................................................................Passed
ruff check...............................................................Passed
Check doxygen headers....................................................Passed
Check license headers....................................................Passed
Check #pragma once.......................................................Passed
Check SYCL #include......................................................Passed
No ssh in git submodules remote..........................................Passed

Test pipeline can run.

Clang-tidy diff report

No relevant changes found.
Well done!

You should now go back to your normal life and enjoy a hopefully sunny day while waiting for the review.

Doxygen diff with main

Removed warnings : 8
New warnings : 8
Warnings count : 7042 → 7042 (0.0%)

Detailed changes :
- src/shammath/include/shammath/AABB.hpp:191: warning: Member contains(AABB other) const noexcept (function) of struct shammath::AABB is not documented.
+ src/shammath/include/shammath/AABB.hpp:195: warning: Member contains(AABB other) const noexcept (function) of struct shammath::AABB is not documented.
- src/shammath/include/shammath/AABB.hpp:27: warning: Compound shammath::Ray is not documented.
+ src/shammath/include/shammath/AABB.hpp:28: warning: Compound shammath::Ray is not documented.
- src/shammath/include/shammath/AABB.hpp:28: warning: Member T_prop (typedef) of struct shammath::Ray is not documented.
+ src/shammath/include/shammath/AABB.hpp:29: warning: Member T_prop (typedef) of struct shammath::Ray is not documented.
- src/shammath/include/shammath/AABB.hpp:29: warning: Member Tscal (typedef) of struct shammath::Ray is not documented.
+ src/shammath/include/shammath/AABB.hpp:30: warning: Member Tscal (typedef) of struct shammath::Ray is not documented.
- src/shammath/include/shammath/AABB.hpp:31: warning: Member origin (variable) of struct shammath::Ray is not documented.
- src/shammath/include/shammath/AABB.hpp:32: warning: Member direction (variable) of struct shammath::Ray is not documented.
+ src/shammath/include/shammath/AABB.hpp:32: warning: Member origin (variable) of struct shammath::Ray is not documented.
+ src/shammath/include/shammath/AABB.hpp:33: warning: Member direction (variable) of struct shammath::Ray is not documented.
- src/shammath/include/shammath/AABB.hpp:33: warning: Member inv_direction (variable) of struct shammath::Ray is not documented.
+ src/shammath/include/shammath/AABB.hpp:34: warning: Member inv_direction (variable) of struct shammath::Ray is not documented.
- src/shammath/include/shammath/AABB.hpp:35: warning: Member Ray(T origin, T direction) (function) of struct shammath::Ray is not documented.
+ src/shammath/include/shammath/AABB.hpp:36: warning: Member Ray(T origin, T direction) (function) of struct shammath::Ray is not documented.

@tdavidcl tdavidcl merged commit 77ab9d4 into Shamrock-code:main Oct 23, 2025
49 checks passed
@tdavidcl tdavidcl deleted the patch-2025-10-22-13-41 branch October 23, 2025 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant