Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Decimal2D.Tests/Decimal2D.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
</ItemGroup>

<ItemGroup>
Expand Down
14 changes: 13 additions & 1 deletion Decimal2D/Arc2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/// <summary>
/// Gets or sets the center of the arc as an XY point.
/// </summary>
Expand Down Expand Up @@ -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" : " "));

}

}
}
14 changes: 13 additions & 1 deletion Decimal2D/Circle2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/// <summary>
/// Returns a new circle with a radius equal to this circle's radius
/// plus the amount specified. Negative amounts are allowed.
Expand Down Expand Up @@ -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" : " "));

}

}
}
3 changes: 2 additions & 1 deletion Decimal2D/Decimal2D.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net50</TargetFrameworks>
<Description>Portable math support for Decimal-based geometric and trigonometric calculations.</Description>
<Authors>Nathan P Jones</Authors>
<PackageId>DecimalMath.Decimal2D</PackageId>
Expand All @@ -16,6 +16,7 @@
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<RepositoryUrl>https://github.com/nathanpjones/DecimalMath.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<AssemblyOriginatorKeyFile>..\sign.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
Expand Down
13 changes: 13 additions & 0 deletions Decimal2D/LineSeg2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/// <summary>
/// Gets or sets the midpoint of the line segment.
/// </summary>
Expand Down
9 changes: 9 additions & 0 deletions Decimal2D/Vector2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public override bool Equals(object obj)
}
return this == (Vector2D)obj;
}

/// <summary>
/// Compares this point against another to the given number of decimal places.
/// </summary>
Expand All @@ -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;
}

/// <summary>
/// Gets whether or not this is a unit vector, i.e. has a magnitude of 1.
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions DecimalEx.Tests/DecimalEx.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion DecimalEx/DecimalEx.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net50</TargetFrameworks>
<Description>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.
Expand All @@ -20,6 +20,8 @@ Also included is other functionality for working with numbers in Decimal precisi
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/nathanpjones/DecimalMath.git</RepositoryUrl>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\sign.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
Expand Down