Skip to content

Commit

Permalink
Fixed typo on Euclidean-related functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris3606 committed Jan 24, 2018
1 parent 4ef5e18 commit 1bbb151
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions GoRogue/Coord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ public static Coord Midpoint(Coord c1, Coord c2) =>
Get((int)Math.Round((c1.X + c2.X) / 2.0f, MidpointRounding.AwayFromZero), (int)Math.Round((c1.Y + c2.Y) / 2.0f, MidpointRounding.AwayFromZero));

/// <summary>
/// Returns the result of the euclidian distance formula, without the square root -- eg., (c2.X - c1.X) * (c2.X - c1.X) + (c2.Y - c1.Y) * (c2.Y - c1.Y).
/// Returns the result of the euclidean distance formula, without the square root -- eg., (c2.X - c1.X) * (c2.X - c1.X) + (c2.Y - c1.Y) * (c2.Y - c1.Y).
/// Use this if you only care about the magnitude of the distance -- eg., if you're trying to compare two distances. Omitting the square root provides
/// a speed increase.
/// </summary>
/// <param name="c1">The first point.</param>
/// <param name="c2">The second point.</param>
/// <returns>The "magnitude" of the euclidian distance between the two points -- basically the distance formula without the square root.</returns>
public static double EuclidianDistanceMagnitude(Coord c1, Coord c2) => (c2.X - c1.X) * (c2.X - c1.X) + (c2.Y - c1.Y) * (c2.Y - c1.Y);
/// <returns>The "magnitude" of the euclidean distance between the two points -- basically the distance formula without the square root.</returns>
public static double EuclideanDistanceMagnitude(Coord c1, Coord c2) => (c2.X - c1.X) * (c2.X - c1.X) + (c2.Y - c1.Y) * (c2.Y - c1.Y);

/// <summary>
/// + operator. Returns the coordinate (c1.X + c2.X, c1.Y + c2.Y).
Expand Down
18 changes: 9 additions & 9 deletions GoRogue/Distance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public enum DistanceType
/// </summary>
MANHATTAN,
/// <summary>
/// Enum type for Distance.EUCLIDIAN.
/// Enum type for Distance.EUCLIDEAN.
/// </summary>
EUCLIDIAN,
EUCLIDEAN,
/// <summary>
/// Enum type for Distance.CHEBYSHEV.
/// </summary>
Expand All @@ -28,7 +28,7 @@ public enum DistanceType
/// <remarks>
/// Provides functions that calculate the distance between two points according to the distance measurement being used. Distance instances
/// can also be explicitly casted to Radius instances -- the 2D radius shape that corresponds to the shape of a "radius" according to the
/// casted distance calculation is retrieved (eg, EUCLIDIAN casts to CIRCLE, MANHATTAN to DIAMOND, etc.)
/// casted distance calculation is retrieved (eg, EUCLIDEAN casts to CIRCLE, MANHATTAN to DIAMOND, etc.)
/// </remarks>
public class Distance
{
Expand All @@ -42,9 +42,9 @@ public class Distance
/// </summary>
public static Distance MANHATTAN = new Distance(DistanceType.MANHATTAN);
/// <summary>
/// EUCLIDIAN distance (equivalent to 8-way movement with extra cost for diagonals).
/// EUCLIDEAN distance (equivalent to 8-way movement with extra cost for diagonals).
/// </summary>
public static Distance EUCLIDIAN = new Distance(DistanceType.EUCLIDIAN);
public static Distance EUCLIDEAN = new Distance(DistanceType.EUCLIDEAN);
/// <summary>
/// CHEBYSHEV distance (equivalent to 8-way movement with no extra cost for diagonals).
/// </summary>
Expand Down Expand Up @@ -174,7 +174,7 @@ public double DistanceOf(double dx, double dy, double dz)
radius = dx + dy + dz; // Simply manhattan distance
break;

case DistanceType.EUCLIDIAN:
case DistanceType.EUCLIDEAN:
radius = Math.Sqrt(dx * dx + dy * dy + dz * dz); // Spherical radius
break;
}
Expand All @@ -193,8 +193,8 @@ public static Distance ToDistance(DistanceType distanceType)
case DistanceType.MANHATTAN:
return MANHATTAN;

case DistanceType.EUCLIDIAN:
return EUCLIDIAN;
case DistanceType.EUCLIDEAN:
return EUCLIDEAN;

case DistanceType.CHEBYSHEV:
return CHEBYSHEV;
Expand All @@ -216,7 +216,7 @@ public static explicit operator Radius(Distance distance)
case DistanceType.MANHATTAN:
return Radius.DIAMOND;

case DistanceType.EUCLIDIAN:
case DistanceType.EUCLIDEAN:
return Radius.CIRCLE;

case DistanceType.CHEBYSHEV:
Expand Down
2 changes: 1 addition & 1 deletion GoRogue/Radius.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static explicit operator Distance(Radius radius)
{
case RadiusType.CIRCLE:
case RadiusType.SPHERE:
return Distance.EUCLIDIAN;
return Distance.EUCLIDEAN;

case RadiusType.DIAMOND:
case RadiusType.OCTAHEDRON:
Expand Down
2 changes: 1 addition & 1 deletion GoRogue/RadiusAreaProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace GoRogue
/// <remarks>
/// In the case that MANHATTAN/CHEBYSHEV distance, or DIAMOND/SQUARE/OCTAHEDRON/CUBE shapes are used,
/// Coords are guaranteed to be returned in order of distance from the center, from least to greatest.
/// This guarantee does NOT hold if EUCLIDIAN distance, or CIRCLE/SPHERE radius shapes are specified.
/// This guarantee does NOT hold if EUCLIDEAN distance, or CIRCLE/SPHERE radius shapes are specified.
///
/// If no bounds are specified, the IEnumerable returned by positions will contain each coordinate
/// within the radius. Otherwise, it will contain each coordinate in the radius that is also within
Expand Down

0 comments on commit 1bbb151

Please sign in to comment.