Skip to content

Commit a783d40

Browse files
authored
Merge pull request #7 from dotnet-campus/t/walterlv/identity
添加判断单位矩阵
2 parents 37d7144 + be03f46 commit a783d40

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

DotNetCampus.Numerics.Geometry/AffineTransformation2DExtensions.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,15 @@ public static bool HasInverse(this AffineTransformation2D transformation)
1616
var det = transformation.M11 * transformation.M22 - transformation.M12 * transformation.M21;
1717
return det != 0;
1818
}
19-
}
19+
20+
/// <summary>
21+
/// 判断是否为单位矩阵的仿射变换。
22+
/// </summary>
23+
/// <param name="transformation">要判断的仿射变换。</param>
24+
/// <returns>如果是单位矩阵,则返回 <see langword="true"/>;否则返回 <see langword="false"/>。</returns>
25+
public static bool IsIdentity(this AffineTransformation2D transformation)
26+
{
27+
ArgumentNullException.ThrowIfNull(transformation);
28+
return transformation is { M11: 1, M12: 0, M21: 0, M22: 1, OffsetX: 0, OffsetY: 0 };
29+
}
30+
}

DotNetCampus.Numerics.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{FF8212D2
1818
.editorconfig = .editorconfig
1919
Directory.Build.props = Directory.Build.props
2020
Directory.Packages.props = Directory.Packages.props
21+
Build\Version.props = Build\Version.props
2122
EndProjectSection
2223
EndProject
2324
Global

0 commit comments

Comments
 (0)