-
Notifications
You must be signed in to change notification settings - Fork 627
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
[4.0] refactored .Math stylecop errors #806
Conversation
* stylecop.props import readded to .Math and fixed all stylecop errors * fixed some xml comment inconsistencies * fixed missing file documentation at top of file(in .Core/Utility/BlittableValueType{T}.cs)
float m21 | ||
) | ||
[SuppressMessage("ReSharper", "SA1117", Justification = "For better readability of Matrix struct.")] | ||
public Matrix3x2( |
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 like the idea of these constructor "shapes", but OpenTK uses the "Allman" brace style, which means you should move the parentheses like this:
public Matrix2x3
(
// arguments
// more arguments
)
I don't think the shape will lose in expressiveness by moving the parentheses a bit
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.
Had a look through, looks mostly good. There are a few things that repeat throughout the PR that need to be fixed - I've put a review comment on the first instance that I found of each issue.
@@ -191,7 +191,7 @@ public Vector4 ToAxisAngle() | |||
/// <summary> | |||
/// Returns a copy of the Quaternion scaled to unit length. | |||
/// </summary> | |||
/// <returns>The normalized copy.</returns> |
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.
Possible loss of information. Should probably keep as "copy" instead of "Quaternion". We know it's a quaternion.
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.
well I'm not too sure on that I mean it's a struct, of course it's a copy
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.
It's more informative than Quaternion; copy semantics are an important facet of the mathematics subsystem.
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.
Agreed with @Nihlus - it's possible if it were badly designed that it would normalize the current instance and THEN return a copy of that.
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.
something I would never expect from any implementation ever, except if the Method name would be Normalize.
But if already two people think so. I'm gonna change it back.
rM12 = right.Row0.Y, | ||
rM21 = right.Row1.X, | ||
rM22 = right.Row1.Y; | ||
float leftM11 = left.Row0.X, |
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.
Don't declare multiple variables this way. Each one gets its own separate declaration.
@@ -781,7 +777,7 @@ public static void Invert(ref Matrix3 mat, out Matrix3 result) | |||
{ | |||
{ mat.Row0.X, mat.Row0.Y, mat.Row0.Z }, | |||
{ mat.Row1.X, mat.Row1.Y, mat.Row1.Z }, | |||
{ mat.Row2.X, mat.Row2.Y, mat.Row2.Z } | |||
{ mat.Row2.X, mat.Row2.Y, mat.Row2.Z }, |
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.
Do not add trailing commas.
result.Row2.Z = (leftM31 * rightM13) + (leftM32 * rightM23) + (leftM33 * rightM33); | ||
result.Row2.W = (leftM31 * rightM14) + (leftM32 * rightM24) + (leftM33 * rightM34) + leftM34; | ||
|
||
/*result.Row0 = (right.Row0 * leftM11 + right.Row1 * leftM12 + right.Row2 * leftM13); |
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.
If this comment is not used, remove it.
@@ -312,6 +304,7 @@ public void Invert() | |||
/// <param name="axis">The axis to rotate about.</param> | |||
/// <param name="angle">Angle in radians to rotate counter-clockwise (looking in the direction of the given axis).</param> | |||
/// <param name="result">A matrix instance.</param> | |||
[SuppressMessage("Microsoft.StyleCop.CSharp.DocumentationRules", "SA1305", Justification = "Is not hungarian notation but abbreveation for precalculated values.")] |
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.
What error is this actually suppressing?
@@ -191,7 +191,7 @@ public Vector4 ToAxisAngle() | |||
/// <summary> | |||
/// Returns a copy of the Quaternion scaled to unit length. | |||
/// </summary> | |||
/// <returns>The normalized copy.</returns> |
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.
something I would never expect from any implementation ever, except if the Method name would be Normalize.
But if already two people think so. I'm gonna change it back.
@@ -354,7 +349,7 @@ public Matrix3 Inverted() | |||
/// <summary> | |||
/// Returns a copy of this Matrix3 without scale. | |||
/// </summary> | |||
/// <returns>The matrix.</returns> | |||
/// <returns>The matrix without scaling.</returns> |
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.
What aboout these ones, because The return value comment here does not specify that it is a copy. Perhaps we should mark such functions as "Pure" as well?
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.
Marking them as pure is a good idea. In general, JetBrains annotations should be used to annotate contracts, purity, and nullability.
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 left this be at first. And I think I will do pure functions in a separate commit(perhaps even separate PR?).
Question is do we want to have the annotations in the public API as well? Because Jetbrains recommends that if we to, to include it directly into the SourceCode instead of using the nuget package.
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.
We'll be using Fody to generate external annotations, which is what we're already doing in the other projects.
* Vector/Quaternion functions not modifying the object(Pure) specify that they return a copied value(again). * declare variables spread over multiple lines(and statements) now * removed some unused code which was commented out * unecessary error supression removed * use Allman brace style for matrix parameters * removed trailing spaces(I could find)
Could you review again please? Don't know if you saw that I did a new commit with hopefully all changes ;) |
@@ -210,7 +210,7 @@ public void Invert() | |||
/// <summary> | |||
/// Returns a copy of this Quaterniond with its rotation angle reversed. | |||
/// </summary> | |||
/// <returns>The inverted copy.</returns> |
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.
Same thing here, loss of information.
@@ -129,7 +129,7 @@ public Vector4h(float x, float y, float z, float w, bool throwOnError) | |||
/// <summary> | |||
/// Initializes a new instance of the <see cref="Vector4h"/> struct. | |||
/// </summary> | |||
/// <param name="v">The <see cref="Vector4"/> to convert.</param> |
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.
Why this change? This constructor explicitly converts a normal vector.
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.
good quetion. I can't remember to have done this probably happened while merging...
Nice job! Just a few nitpicks left. |
* fixed a mistake from wrong merge choice * fixed two missed return value descriptions(added information that a copy is returned)
* implemented double precision for MathHelper.InverseSqrtFast
@@ -189,23 +189,20 @@ public static float InverseSqrtFast(float x) | |||
/// which is found in the Quake III source code. This implementation comes from | |||
/// http://www.codemaestro.com/reviews/review00000105.html. For the history of this method, see | |||
/// http://www.beyond3d.com/content/articles/8/. | |||
/// double magic number from: https://cs.uwaterloo.ca/~m32rober/rsqrt.pdf | |||
/// chapter 4.8. | |||
/// </remarks> | |||
public static double InverseSqrtFast(double x) |
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.
fixed this one as well, because it was a pretty easy and fast one. And I think it would still fit in here, because everything was in .Math.
Edit: More important is actually the Method body
Spankin'. Thanks a ton! |
Purpose of this PR
Testing status
Well it does build and it shouldn't have any major implementation changes.
Comments
fixed some stuff of #802 and now in a feature branch. I hope the simple naming is enough.
I did not reorder static variables, because there still seems to be a discussion about that.