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

[4.0] refactored .Math stylecop errors #806

Merged
merged 4 commits into from
Aug 24, 2018
Merged

[4.0] refactored .Math stylecop errors #806

merged 4 commits into from
Aug 24, 2018

Conversation

jvbsl
Copy link
Contributor

@jvbsl jvbsl commented Aug 23, 2018

Purpose of this PR

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

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.

* 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)
@jvbsl jvbsl mentioned this pull request Aug 23, 2018
Closed
float m21
)
[SuppressMessage("ReSharper", "SA1117", Justification = "For better readability of Matrix struct.")]
public Matrix3x2(
Copy link
Contributor

@FreezyLemon FreezyLemon Aug 23, 2018

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

Copy link
Contributor

@Nihlus Nihlus left a 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>
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Contributor Author

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,
Copy link
Contributor

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 },
Copy link
Contributor

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);
Copy link
Contributor

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.")]
Copy link
Contributor

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>
Copy link
Contributor Author

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>
Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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)
@jvbsl
Copy link
Contributor Author

jvbsl commented Aug 24, 2018

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>
Copy link
Contributor

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>
Copy link
Contributor

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.

Copy link
Contributor Author

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

@Nihlus
Copy link
Contributor

Nihlus commented Aug 24, 2018

Nice job! Just a few nitpicks left.

jvbsl added 2 commits August 24, 2018 20:39
* 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)
Copy link
Contributor Author

@jvbsl jvbsl Aug 24, 2018

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

@Nihlus
Copy link
Contributor

Nihlus commented Aug 24, 2018

Spankin'. Thanks a ton!

@Nihlus Nihlus merged commit 997c902 into opentk:4.0 Aug 24, 2018
@jvbsl jvbsl deleted the feature/refactor branch August 24, 2018 19:14
@varon varon added this to Done in OpenTK 4.0 Oct 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
OpenTK 4.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants