Skip to content

Commit

Permalink
Remove unnecessary parentheses
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahStolk committed Jun 16, 2024
1 parent f5f7e10 commit 3338d2e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Detach/Collisions/Geometry2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static bool LineLine(LineSegment2D line1, LineSegment2D line2)

float Cross(Vector2 v1, Vector2 v2)
{
return (v1.X * v2.Y) - (v1.Y * v2.X);
return v1.X * v2.Y - v1.Y * v2.X;
}
}

Expand All @@ -97,8 +97,8 @@ public static bool LineRectangle(LineSegment2D line, Rectangle rectangle)
return true;

Vector2 norm = Vector2.Normalize(line.End - line.Start);
norm.X = (norm.X != 0) ? 1 / norm.X : 0;
norm.Y = (norm.Y != 0) ? 1 / norm.Y : 0;
norm.X = norm.X != 0 ? 1 / norm.X : 0;

Check warning on line 100 in src/Detach/Collisions/Geometry2D.cs

View workflow job for this annotation

GitHub Actions / build

Do not check floating point inequality with exact values, use a range instead. (https://rules.sonarsource.com/csharp/RSPEC-1244)
norm.Y = norm.Y != 0 ? 1 / norm.Y : 0;

Check warning on line 101 in src/Detach/Collisions/Geometry2D.cs

View workflow job for this annotation

GitHub Actions / build

Do not check floating point inequality with exact values, use a range instead. (https://rules.sonarsource.com/csharp/RSPEC-1244)
Vector2 min = (rectangle.GetMin() - line.Start) * norm;
Vector2 max = (rectangle.GetMax() - line.Start) * norm;

Expand All @@ -107,7 +107,7 @@ public static bool LineRectangle(LineSegment2D line, Rectangle rectangle)
if (tMax < 0 || tMin > tMax)
return false;

float t = (tMin < 0) ? tMax : tMin;
float t = tMin < 0 ? tMax : tMin;
return t > 0 && t * t < line.LengthSquared;
}

Expand Down

0 comments on commit 3338d2e

Please sign in to comment.