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

Remove repetitive code at Contact, on relative velocity calculation #305

Open
diogomene opened this issue Nov 28, 2024 · 0 comments · May be fixed by #306
Open

Remove repetitive code at Contact, on relative velocity calculation #305

diogomene opened this issue Nov 28, 2024 · 0 comments · May be fixed by #306

Comments

@diogomene
Copy link

While analyzing the Contact class source code using Qodana, a duplication was identified in the calculations of the relative velocity at the contact point between two bodies:

matrix.zeroVec2(dv1);
matrix.plusVec2(dv1, vB);
matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));
matrix.minusVec2(dv1, vA);
matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));

This set of instructions is repeated three times across the methods of the Contact class, with no apparent occurrences in other classes. Duplicated code can increase complexity for future maintainers, making the code harder to read and modify. Any changes to the calculation logic would require updates in multiple locations, raising the likelihood of errors or inconsistencies.

To address this issue, I suggest extracting the duplicated instructions into a dedicated method within the Contact class. Centralizing these operations would make the code cleaner, easier to read, and less prone to errors, as any modifications would only need to be made in a single location. This approach would improve maintainability and ensure consistency throughout the code.

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

Successfully merging a pull request may close this issue.

1 participant