refactor: Equals methods to use equality operators on primitives
This commit is contained in:
parent
767fc28488
commit
dae6549bad
@ -142,7 +142,7 @@ public readonly struct ColorHSV(float hue, float saturation, float value)
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to compare with the current <see cref="ColorHSV"/>.</param>
|
||||
/// <returns><see cref="true"/> if the specified object is equal to the current <see cref="ColorHSV"/>; otherwise, <see cref="false"/>.</returns>
|
||||
public override bool Equals(object? obj) => obj is ColorHSV colorHSV && Hue.Equals(colorHSV.Hue) && Saturation.Equals(colorHSV.Saturation) && Value.Equals(colorHSV.Value);
|
||||
public override bool Equals(object? obj) => obj is ColorHSV colorHSV && this == colorHSV;
|
||||
|
||||
/// <summary>
|
||||
/// Generates a hash code for the <see cref="ColorHSV"/>.
|
||||
|
@ -124,7 +124,7 @@ public readonly struct ColorRGB(byte r, byte g, byte b)
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to compare with the current <see cref="ColorRGB"/>.</param>
|
||||
/// <returns><see cref="true"/> if the specified object is equal to the current <see cref="ColorRGB"/>; otherwise, <see cref="false"/>.</returns>
|
||||
public override bool Equals(object? obj) => obj is ColorRGB colorRGB && R.Equals(colorRGB.R) && G.Equals(colorRGB.G) && B.Equals(colorRGB.B);
|
||||
public override bool Equals(object? obj) => obj is ColorRGB colorRGB && this == colorRGB;
|
||||
|
||||
/// <summary>
|
||||
/// Generates a hash code for the <see cref="ColorRGB"/>.
|
||||
|
@ -107,7 +107,7 @@ public readonly struct ColorRGBA(byte r, byte g, byte b, byte a = 255)
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to compare with the current <see cref="ColorRGBA"/>.</param>
|
||||
/// <returns><see cref="true"/> if the specified object is equal to the current <see cref="ColorRGBA"/>; otherwise, <see cref="false"/>.</returns>
|
||||
public override bool Equals(object? obj) => obj is ColorRGBA colorRGBA && R.Equals(colorRGBA.R) && G.Equals(colorRGBA.G) && B.Equals(colorRGBA.B) && A.Equals(colorRGBA.A);
|
||||
public override bool Equals(object? obj) => obj is ColorRGBA colorRGBA && this == colorRGBA;
|
||||
|
||||
/// <summary>
|
||||
/// Generates a hash code for the <see cref="ColorRGBA"/>.
|
||||
|
@ -287,7 +287,7 @@ public readonly struct Quaternion(float x, float y, float z, float w)
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to compare with the current <see cref="Quaternion"/>.</param>
|
||||
/// <returns><see cref="true"/> if the specified object is equal to the current <see cref="Quaternion"/>; otherwise, <see cref="false"/>.</returns>
|
||||
public override bool Equals(object? obj) => obj is Quaternion quaternion && X.Equals(quaternion.X) && Y.Equals(quaternion.Y) && Z.Equals(quaternion.Z) && W.Equals(quaternion.W);
|
||||
public override bool Equals(object? obj) => obj is Quaternion quaternion && this == quaternion;
|
||||
|
||||
/// <summary>
|
||||
/// Generates a hash code for the <see cref="Quaternion"/>.
|
||||
|
@ -22,6 +22,8 @@ public readonly struct Ray2D(Vector2D Origin, Vector2D Direction)
|
||||
/// </summary>
|
||||
public readonly Ray2D Reversed => new(Origin, -Direction);
|
||||
|
||||
public static bool operator ==(Ray2D left, Ray2D right) => left.Origin == right.Origin;
|
||||
public static bool operator !=(Ray2D left, Ray2D right) => left.Origin != right.Origin;
|
||||
public static implicit operator Ray2D(Line2D line) => new(line.From, line.From.FromTo(line.To).Normalized);
|
||||
|
||||
/// <summary>
|
||||
|
@ -307,7 +307,7 @@ public readonly struct Vector2D(float x, float y)
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to compare with the current <see cref="Vector2D"/>.</param>
|
||||
/// <returns><see cref="true"/> if the specified object is equal to the current <see cref="Vector2D"/>; otherwise, <see cref="false"/>.</returns>
|
||||
public override bool Equals(object? obj) => obj is Vector2D vector2D && X.Equals(vector2D.X) && Y.Equals(vector2D.Y);
|
||||
public override bool Equals(object? obj) => obj is Vector2D vector2D && this == vector2D;
|
||||
|
||||
/// <summary>
|
||||
/// Generates a hash code for the <see cref="Vector2D"/>.
|
||||
|
@ -276,7 +276,7 @@ public readonly struct Vector3D(float x, float y, float z)
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to compare with the current <see cref="Vector3D"/>.</param>
|
||||
/// <returns><see cref="true"/> if the specified object is equal to the current <see cref="Vector3D"/>; otherwise, <see cref="false"/>.</returns>
|
||||
public override bool Equals(object? obj) => obj is Vector3D vector3D && X.Equals(vector3D.X) && Y.Equals(vector3D.Y) && Z.Equals(vector3D.Z);
|
||||
public override bool Equals(object? obj) => obj is Vector3D vector3D && this == vector3D;
|
||||
|
||||
/// <summary>
|
||||
/// Generates a hash code for the <see cref="Vector3D"/>.
|
||||
|
Loading…
x
Reference in New Issue
Block a user