diff --git a/Decimal2D.Tests/Decimal2D.Tests.csproj b/Decimal2D.Tests/Decimal2D.Tests.csproj index 2249c0f..831f3b7 100644 --- a/Decimal2D.Tests/Decimal2D.Tests.csproj +++ b/Decimal2D.Tests/Decimal2D.Tests.csproj @@ -1,13 +1,13 @@  - netcoreapp2.2 + net472 - + - + diff --git a/Decimal2D/Arc2D.cs b/Decimal2D/Arc2D.cs index e9002a7..713ab18 100644 --- a/Decimal2D/Arc2D.cs +++ b/Decimal2D/Arc2D.cs @@ -169,6 +169,19 @@ public static Arc2D FromPointsOnArc(Point2D endPointA, Point2D endPointB, Point2 return objA.Circle != objB.Circle || objA._startAngle != objB._startAngle || objA._endAngle != objB._endAngle; } + public override bool Equals(object obj) + { + return obj is Arc2D other && other == this; + } + public override int GetHashCode() + { + int hashCode = 146115040; + hashCode = hashCode * -1521134295 + Circle.GetHashCode(); + hashCode = hashCode * -1521134295 + _startAngle.GetHashCode(); + hashCode = hashCode * -1521134295 + _endAngle.GetHashCode(); + return hashCode; + } + /// /// Gets or sets the center of the arc as an XY point. /// @@ -410,6 +423,5 @@ public string ToAutoCADCmd(bool linefeedTerminate = true) return string.Format("_arc {0},{1} c {2},{3} {4},{5}{6}", StartPt.X, StartPt.Y, Circle.Center.X, Circle.Center.Y, EndPt.X, EndPt.Y, (linefeedTerminate ? "\r\n" : " ")); } - } } diff --git a/Decimal2D/Circle2D.cs b/Decimal2D/Circle2D.cs index 81d4b15..b7eddfb 100644 --- a/Decimal2D/Circle2D.cs +++ b/Decimal2D/Circle2D.cs @@ -135,6 +135,19 @@ public Circle2D(Point2D pt1, Point2D pt2) return objA.Center != objB.Center || objA._radius != objB._radius; } + public override bool Equals(object obj) + { + return obj is Circle2D other && other == this; + } + + public override int GetHashCode() + { + int hashCode = 1922506679; + hashCode = hashCode * -1521134295 + _center.GetHashCode(); + hashCode = hashCode * -1521134295 + _radius.GetHashCode(); + return hashCode; + } + /// /// Returns a new circle with a radius equal to this circle's radius /// plus the amount specified. Negative amounts are allowed. @@ -1257,6 +1270,5 @@ public string ToAutoCADCmd(bool linefeedTerminate = true) return string.Format("_circle {0},{1} {2}{3}", _center.X, _center.Y, _radius, (linefeedTerminate ? "\r\n" : " ")); } - } } diff --git a/Decimal2D/Decimal2D.csproj b/Decimal2D/Decimal2D.csproj index 774bff0..f1fb539 100644 --- a/Decimal2D/Decimal2D.csproj +++ b/Decimal2D/Decimal2D.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netstandard2.0;netcoreapp3.1;net50 Portable math support for Decimal-based geometric and trigonometric calculations. Nathan P Jones DecimalMath.Decimal2D @@ -16,6 +16,7 @@ false https://github.com/nathanpjones/DecimalMath.git git + ..\sign.pfx diff --git a/Decimal2D/LineSeg2D.cs b/Decimal2D/LineSeg2D.cs index 47a8127..518220f 100644 --- a/Decimal2D/LineSeg2D.cs +++ b/Decimal2D/LineSeg2D.cs @@ -51,6 +51,19 @@ public LineSeg2D(decimal x1, decimal y1, decimal x2, decimal y2) return (lineSegA.Pt1 == lineSegB.Pt1) && (lineSegA.Pt2 == lineSegB.Pt2); } + public override bool Equals(object obj) + { + return obj is LineSeg2D other && other == this; + } + + public override int GetHashCode() + { + int hashCode = -913818983; + hashCode = hashCode * -1521134295 + Pt1.GetHashCode(); + hashCode = hashCode * -1521134295 + Pt2.GetHashCode(); + return hashCode; + } + /// /// Gets or sets the midpoint of the line segment. /// diff --git a/Decimal2D/Vector2D.cs b/Decimal2D/Vector2D.cs index 5083fbe..f93d908 100644 --- a/Decimal2D/Vector2D.cs +++ b/Decimal2D/Vector2D.cs @@ -105,6 +105,7 @@ public override bool Equals(object obj) } return this == (Vector2D)obj; } + /// /// Compares this point against another to the given number of decimal places. /// @@ -124,6 +125,14 @@ public bool Equals(Vector2D other, int decimals) return objA.X != objB.X || objA.Y != objB.Y; } + public override int GetHashCode() + { + int hashCode = 1861411795; + hashCode = hashCode * -1521134295 + X.GetHashCode(); + hashCode = hashCode * -1521134295 + Y.GetHashCode(); + return hashCode; + } + /// /// Gets whether or not this is a unit vector, i.e. has a magnitude of 1. /// diff --git a/DecimalEx.Tests/DecimalEx.Tests.csproj b/DecimalEx.Tests/DecimalEx.Tests.csproj index 9ba40dd..98b1c2c 100644 --- a/DecimalEx.Tests/DecimalEx.Tests.csproj +++ b/DecimalEx.Tests/DecimalEx.Tests.csproj @@ -1,13 +1,13 @@  - netcoreapp2.2 + net472 - + - + diff --git a/DecimalEx/DecimalEx.csproj b/DecimalEx/DecimalEx.csproj index 5c0b7f0..e704622 100644 --- a/DecimalEx/DecimalEx.csproj +++ b/DecimalEx/DecimalEx.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netstandard2.0;netcoreapp3.1;net50 Portable math support for Decimal that Microsoft forgot and more. Includes Decimal versions of Sqrt, Pow, Exp, and Log as well as the trig functions Sin, Cos, Tan, ASin, ACos, ATan, ATan2. @@ -20,6 +20,8 @@ Also included is other functionality for working with numbers in Decimal precisi false git https://github.com/nathanpjones/DecimalMath.git + true + ..\sign.pfx