├── .github
└── workflows
│ ├── demo.yml
│ ├── metrics.yml
│ ├── nuget.yml
│ └── test.yml
├── .gitignore
├── Aptacode.Geometry.sln
├── Benchmarks
├── Benchmarks.csproj
├── CreationBenchmark.cs
├── EllipseCollisionBenchmarks.cs
├── FastAndDirtyConfig.cs
├── Logo.ico
├── PointCollisionBenchmarks.cs
└── Program.cs
├── CODE_METRICS.md
├── Demo
├── App.razor
├── Demo.csproj
├── Pages
│ ├── Ascii.razor
│ ├── Ascii.razor.cs
│ ├── Benchmark
│ │ ├── Benchmark.razor
│ │ ├── Benchmark.razor.cs
│ │ ├── GeometryProfileFunctions.cs
│ │ ├── PrimitiveCreation.cs
│ │ ├── PrimitiveFunction.cs
│ │ ├── ProfileFunction.cs
│ │ ├── ProfileFunctionResult.cs
│ │ ├── ProfileHelpers.cs
│ │ └── ProfileRunner.cs
│ ├── Canvas.razor
│ ├── Canvas.razor.cs
│ ├── Index.razor
│ └── Index.razor.cs
├── Program.cs
├── Properties
│ └── launchSettings.json
├── Shared
│ ├── MainLayout.razor
│ └── MainLayout.razor.css
├── _Imports.razor
└── wwwroot
│ ├── css
│ ├── app.css
│ ├── bootstrap
│ │ ├── bootstrap.min.css
│ │ └── bootstrap.min.css.map
│ └── open-iconic
│ │ ├── FONT-LICENSE
│ │ ├── ICON-LICENSE
│ │ ├── README.md
│ │ └── font
│ │ ├── css
│ │ └── open-iconic-bootstrap.min.css
│ │ └── fonts
│ │ ├── open-iconic.eot
│ │ ├── open-iconic.otf
│ │ ├── open-iconic.svg
│ │ ├── open-iconic.ttf
│ │ └── open-iconic.woff
│ ├── favicon.ico
│ ├── icon-192.png
│ └── index.html
├── Geometry
├── Collision
│ ├── LineSegmentCollisionDetectionMethods.cs
│ ├── PrimitiveCollisionDetectionMethods.cs
│ └── Vector2CollisionDetectionMethods.cs
├── Constants.cs
├── Geometry.csproj
├── Logo.ico
├── Primitives
│ ├── Circle.cs
│ ├── Point.cs
│ ├── PolyLine.cs
│ ├── Polygon.cs
│ └── Primitive.cs
├── Utilities
│ └── Vector2Extensions.cs
└── Vertices
│ └── VertexArrayExtensions.cs
├── LICENSE
├── README.md
├── Resources
└── Images
│ ├── Banner.afdesign
│ ├── Banner.jpg
│ ├── Banner.png
│ ├── Logo.afdesign
│ ├── Logo.ico
│ ├── Logo.jpg
│ └── Logo.png
├── Tests
├── Collision
│ ├── CircleHelper_Tests.cs
│ ├── Collision_Tests.cs
│ ├── PointCollisionTestData
│ │ ├── EllipseVector2CollisionTestDataGenerator.cs
│ │ ├── PointVector2CollisionTestDataGenerator.cs
│ │ ├── PolygonVector2CollisionTestDataGenerator.cs
│ │ └── PolylineVector2CollisionTestDataGenerator.cs
│ └── PrimitiveCollisionTestData
│ │ ├── EllipsePrimitiveCollisionTestDataGenerator.cs
│ │ ├── PointPrimitiveCollisionTestDataGenerator.cs
│ │ ├── PolygonPrimitiveCollisionTestDataGenerator.cs
│ │ └── PolylinePrimitiveCollisionTestDataGenerator.cs
├── Logo.ico
├── Primitives
│ ├── Creation
│ │ ├── EllipseCreationTestDataGenerator.cs
│ │ ├── PointCreationTestDataGenerator.cs
│ │ ├── PolygonCreationTestDataGenerator.cs
│ │ ├── PolylineCreationTestDataGenerator.cs
│ │ └── PrimitiveCreationTests.cs
│ ├── Equality
│ │ ├── EllipseEqualityTestDataGenerator.cs
│ │ ├── PointEqualityTestDataGenerator.cs
│ │ ├── PolygonEqualityTestDataGenerator.cs
│ │ ├── PolylineEqualityTestDataGenerator.cs
│ │ └── PrimitiveEqualityTests.cs
│ ├── ToString
│ │ ├── EllipseToStringTestDataGenerator.cs
│ │ ├── PointToStringTestDataGenerator.cs
│ │ ├── PolygonToStringTestDataGenerator.cs
│ │ ├── PolylineToStringTestDataGenerator.cs
│ │ └── PrimitiveToStringTests.cs
│ └── Transformation
│ │ ├── PrimitiveTransformationTests.cs
│ │ ├── Scale
│ │ ├── EllipseCenterScaleTestDataGenerator.cs
│ │ ├── PointCenterScaleTestDataGenerator.cs
│ │ ├── PolygonCenterScaleTestDataGenerator.cs
│ │ └── PolylineCenterScaleTestDataGenerator.cs
│ │ └── Translate
│ │ ├── EllipseTranslationTestDataGenerator.cs
│ │ ├── PointTranslationTestDataGenerator.cs
│ │ ├── PolygonTranslationTestDataGenerator.cs
│ │ └── PolylineTranslationTestDataGenerator.cs
├── Tests.csproj
└── UnitTests.cs
├── development-azure-pipelines.yml
└── production-azure-pipelines.yml
/.github/workflows/demo.yml:
--------------------------------------------------------------------------------
1 | name: demo
2 |
3 | env:
4 | dotnet_version: 7.0.x
5 | project_name: "Demo/Demo.csproj"
6 | base_href: /Geometry/
7 | target_framework: net7.0
8 |
9 | on:
10 | push:
11 | pull_request:
12 | branches: [ main ]
13 | paths-ignore:
14 | - 'README.md'
15 |
16 | jobs:
17 | build:
18 |
19 | runs-on: ubuntu-latest
20 |
21 | steps:
22 | - uses: actions/checkout@v2
23 | - name: Setup .NET
24 | uses: actions/setup-dotnet@v1
25 | with:
26 | dotnet-version: ${{ env.dotnet_version }}
27 | - name: Install dependencies
28 | run: dotnet restore
29 | - name: Build
30 | run: dotnet build -c Release --no-restore
31 | - name: Publish
32 | run: dotnet publish ${{ env.project_name }} -f ${{ env.target_framework }} -c Release -o app/publish --no-restore | dotnet publish ${{ env.project_name }} -f ${{ env.target_framework }} -c Release -o app/publish --no-restore -p:PublishTrimmed=false
33 | - name: Rewrite base href
34 | uses: SteveSandersonMS/ghaction-rewrite-base-href@v1
35 | with:
36 | html_path: app/publish/wwwroot/index.html
37 | base_href: ${{ env.base_href }}
38 | - name: add .nojekyll
39 | run: touch app/publish/wwwroot/.nojekyll
40 | - name: write git commit id
41 | run: echo -n "${GITHUB_SHA}" > app/publish/wwwroot/commit.txt
42 | - name: Deploy to Github Pages
43 | uses: JamesIves/github-pages-deploy-action@releases/v3
44 | with:
45 | ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
46 | BASE_BRANCH: main # The branch the action should deploy from.
47 | BRANCH: gh-pages # The branch the action should deploy to.
48 | FOLDER: app/publish/wwwroot # The folder the action should deploy.
49 | SINGLE_COMMIT: true
50 |
--------------------------------------------------------------------------------
/.github/workflows/metrics.yml:
--------------------------------------------------------------------------------
1 | name: 'code metrics'
2 |
3 | on:
4 | push:
5 | branches: [ main ]
6 | paths:
7 | - '!./CODE_METRICS.md' # ignore this file
8 |
9 | workflow_dispatch:
10 | inputs:
11 | reason:
12 | description: 'The reason for running the workflow'
13 | required: true
14 | default: 'Manual run'
15 |
16 | jobs:
17 | build:
18 |
19 | runs-on: ubuntu-latest
20 |
21 | steps:
22 | - uses: actions/checkout@v2
23 |
24 | - name: 'Print manual run reason'
25 | if: ${{ github.event_name == 'workflow_dispatch' }}
26 | run: |
27 | echo 'Reason: ${{ github.event.inputs.reason }}'
28 | - name: .NET code metrics
29 | id: dotnet-code-metrics
30 | uses: dotnet/samples/github-actions/DotNet.GitHubAction@main
31 | env:
32 | GREETINGS: 'Hello, .NET developers!' # ${{ secrets.GITHUB_TOKEN }}
33 | with:
34 | owner: ${{ github.repository_owner }}
35 | name: ${{ github.repository }}
36 | branch: ${{ github.ref }}
37 | dir: ${{ './' }}
38 |
39 | - name: Create pull request
40 | uses: peter-evans/create-pull-request@v3.4.1
41 | if: ${{ steps.dotnet-code-metrics.outputs.updated-metrics }} == 'true'
42 | with:
43 | title: '${{ steps.dotnet-code-metrics.outputs.summary-title }}'
44 | body: '${{ steps.dotnet-code-metrics.outputs.summary-details }}'
45 | commit-message: '.NET code metrics, automated pull request.'
46 |
--------------------------------------------------------------------------------
/.github/workflows/nuget.yml:
--------------------------------------------------------------------------------
1 | name: nuget
2 | env:
3 | dotnet_version: 7.0.x
4 | on:
5 | push:
6 | branches:
7 | - main
8 | pull_request:
9 | types: [closed]
10 | branches:
11 | - main
12 |
13 | jobs:
14 | build:
15 | runs-on: ubuntu-18.04
16 | name: Update NuGet package
17 | steps:
18 | - uses: actions/checkout@v2
19 | - name: Setup .NET
20 | uses: actions/setup-dotnet@v1
21 | with:
22 | dotnet-version: ${{ env.dotnet_version }}
23 | - name: Restore
24 | run: dotnet restore
25 | - name: Build
26 | run: dotnet build -c Release --no-restore
27 | - name: Pack
28 | run: dotnet pack -c Release -o out
29 | - name: Push
30 | run: dotnet nuget push ./out/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_TOKEN}} --skip-duplicate --no-symbols true
31 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | # The name of the workflow.
2 | # This is the name that's displayed for status
3 | # badges (commonly embedded in README.md files).
4 | name: tests
5 |
6 | # Trigger this workflow on a push, or pull request to
7 | # the production branch, when either C# or project files changed
8 | on:
9 | push:
10 | pull_request:
11 | branches: [ main ]
12 | paths-ignore:
13 | - 'README.md'
14 |
15 | # Create an environment variable named DOTNET_VERSION
16 | # and set it as "6.0.x"
17 | env:
18 | DOTNET_VERSION: '7.0.x' # The .NET SDK version to use
19 |
20 | # Defines a single job named "build-and-test"
21 | jobs:
22 | build-and-test:
23 |
24 | # When the workflow runs, this is the name that is logged
25 | # This job will run three times, once for each "os" defined
26 | name: build-and-test-${{matrix.os}}
27 | runs-on: ${{ matrix.os }}
28 | strategy:
29 | matrix:
30 | os: [ubuntu-latest, windows-latest, macOS-latest]
31 |
32 | # Each job run contains these five steps
33 | steps:
34 |
35 | # 1) Check out the source code so that the workflow can access it.
36 | - uses: actions/checkout@v2
37 |
38 | # 2) Set up the .NET CLI environment for the workflow to use.
39 | # The .NET version is specified by the environment variable.
40 | - name: Setup .NET
41 | uses: actions/setup-dotnet@v1
42 | with:
43 | dotnet-version: ${{ env.DOTNET_VERSION }}
44 |
45 | # 3) Restore the dependencies and tools of a project or solution.
46 | - name: Install dependencies
47 | run: dotnet restore
48 |
49 | # 4) Build a project or solution and all of its dependencies.
50 | - name: Build
51 | run: dotnet build --configuration Release --no-restore
52 |
53 | # 5) Test a project or solution.
54 | - name: Test
55 | run: dotnet test --no-restore --verbosity normal
56 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUnit
47 | *.VisualState.xml
48 | TestResult.xml
49 | nunit-*.xml
50 |
51 | # Build Results of an ATL Project
52 | [Dd]ebugPS/
53 | [Rr]eleasePS/
54 | dlldata.c
55 |
56 | # Benchmark Results
57 | BenchmarkDotNet.Artifacts/
58 |
59 | # .NET Core
60 | project.lock.json
61 | project.fragment.lock.json
62 | artifacts/
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_h.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *_wpftmp.csproj
88 | *.log
89 | *.vspscc
90 | *.vssscc
91 | .builds
92 | *.pidb
93 | *.svclog
94 | *.scc
95 |
96 | # Chutzpah Test files
97 | _Chutzpah*
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opendb
104 | *.opensdf
105 | *.sdf
106 | *.cachefile
107 | *.VC.db
108 | *.VC.VC.opendb
109 |
110 | # Visual Studio profiler
111 | *.psess
112 | *.vsp
113 | *.vspx
114 | *.sap
115 |
116 | # Visual Studio Trace Files
117 | *.e2e
118 |
119 | # TFS 2012 Local Workspace
120 | $tf/
121 |
122 | # Guidance Automation Toolkit
123 | *.gpState
124 |
125 | # ReSharper is a .NET coding add-in
126 | _ReSharper*/
127 | *.[Rr]e[Ss]harper
128 | *.DotSettings.user
129 |
130 | # TeamCity is a build add-in
131 | _TeamCity*
132 |
133 | # DotCover is a Code Coverage Tool
134 | *.dotCover
135 |
136 | # AxoCover is a Code Coverage Tool
137 | .axoCover/*
138 | !.axoCover/settings.json
139 |
140 | # Visual Studio code coverage results
141 | *.coverage
142 | *.coveragexml
143 |
144 | # NCrunch
145 | _NCrunch_*
146 | .*crunch*.local.xml
147 | nCrunchTemp_*
148 |
149 | # MightyMoose
150 | *.mm.*
151 | AutoTest.Net/
152 |
153 | # Web workbench (sass)
154 | .sass-cache/
155 |
156 | # Installshield output folder
157 | [Ee]xpress/
158 |
159 | # DocProject is a documentation generator add-in
160 | DocProject/buildhelp/
161 | DocProject/Help/*.HxT
162 | DocProject/Help/*.HxC
163 | DocProject/Help/*.hhc
164 | DocProject/Help/*.hhk
165 | DocProject/Help/*.hhp
166 | DocProject/Help/Html2
167 | DocProject/Help/html
168 |
169 | # Click-Once directory
170 | publish/
171 |
172 | # Publish Web Output
173 | *.[Pp]ublish.xml
174 | *.azurePubxml
175 | # Note: Comment the next line if you want to checkin your web deploy settings,
176 | # but database connection strings (with potential passwords) will be unencrypted
177 | *.pubxml
178 | *.publishproj
179 |
180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
181 | # checkin your Azure Web App publish settings, but sensitive information contained
182 | # in these scripts will be unencrypted
183 | PublishScripts/
184 |
185 | # NuGet Packages
186 | *.nupkg
187 | # NuGet Symbol Packages
188 | *.snupkg
189 | # The packages folder can be ignored because of Package Restore
190 | **/[Pp]ackages/*
191 | # except build/, which is used as an MSBuild target.
192 | !**/[Pp]ackages/build/
193 | # Uncomment if necessary however generally it will be regenerated when needed
194 | #!**/[Pp]ackages/repositories.config
195 | # NuGet v3's project.json files produces more ignorable files
196 | *.nuget.props
197 | *.nuget.targets
198 |
199 | # Microsoft Azure Build Output
200 | csx/
201 | *.build.csdef
202 |
203 | # Microsoft Azure Emulator
204 | ecf/
205 | rcf/
206 |
207 | # Windows Store app package directories and files
208 | AppPackages/
209 | BundleArtifacts/
210 | Package.StoreAssociation.xml
211 | _pkginfo.txt
212 | *.appx
213 | *.appxbundle
214 | *.appxupload
215 |
216 | # Visual Studio cache files
217 | # files ending in .cache can be ignored
218 | *.[Cc]ache
219 | # but keep track of directories ending in .cache
220 | !?*.[Cc]ache/
221 |
222 | # Others
223 | ClientBin/
224 | ~$*
225 | *~
226 | *.dbmdl
227 | *.dbproj.schemaview
228 | *.jfm
229 | *.pfx
230 | *.publishsettings
231 | orleans.codegen.cs
232 |
233 | # Including strong name files can present a security risk
234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
235 | #*.snk
236 |
237 | # Since there are multiple workflows, uncomment next line to ignore bower_components
238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
239 | #bower_components/
240 |
241 | # RIA/Silverlight projects
242 | Generated_Code/
243 |
244 | # Backup & report files from converting an old project file
245 | # to a newer Visual Studio version. Backup files are not needed,
246 | # because we have git ;-)
247 | _UpgradeReport_Files/
248 | Backup*/
249 | UpgradeLog*.XML
250 | UpgradeLog*.htm
251 | ServiceFabricBackup/
252 | *.rptproj.bak
253 |
254 | # SQL Server files
255 | *.mdf
256 | *.ldf
257 | *.ndf
258 |
259 | # Business Intelligence projects
260 | *.rdl.data
261 | *.bim.layout
262 | *.bim_*.settings
263 | *.rptproj.rsuser
264 | *- [Bb]ackup.rdl
265 | *- [Bb]ackup ([0-9]).rdl
266 | *- [Bb]ackup ([0-9][0-9]).rdl
267 |
268 | # Microsoft Fakes
269 | FakesAssemblies/
270 |
271 | # GhostDoc plugin setting file
272 | *.GhostDoc.xml
273 |
274 | # Node.js Tools for Visual Studio
275 | .ntvs_analysis.dat
276 | node_modules/
277 |
278 | # Visual Studio 6 build log
279 | *.plg
280 |
281 | # Visual Studio 6 workspace options file
282 | *.opt
283 |
284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
285 | *.vbw
286 |
287 | # Visual Studio LightSwitch build output
288 | **/*.HTMLClient/GeneratedArtifacts
289 | **/*.DesktopClient/GeneratedArtifacts
290 | **/*.DesktopClient/ModelManifest.xml
291 | **/*.Server/GeneratedArtifacts
292 | **/*.Server/ModelManifest.xml
293 | _Pvt_Extensions
294 |
295 | # Paket dependency manager
296 | .paket/paket.exe
297 | paket-files/
298 |
299 | # FAKE - F# Make
300 | .fake/
301 |
302 | # CodeRush personal settings
303 | .cr/personal
304 |
305 | # Python Tools for Visual Studio (PTVS)
306 | __pycache__/
307 | *.pyc
308 |
309 | # Cake - Uncomment if you are using it
310 | # tools/**
311 | # !tools/packages.config
312 |
313 | # Tabs Studio
314 | *.tss
315 |
316 | # Telerik's JustMock configuration file
317 | *.jmconfig
318 |
319 | # BizTalk build output
320 | *.btp.cs
321 | *.btm.cs
322 | *.odx.cs
323 | *.xsd.cs
324 |
325 | # OpenCover UI analysis results
326 | OpenCover/
327 |
328 | # Azure Stream Analytics local run output
329 | ASALocalRun/
330 |
331 | # MSBuild Binary and Structured Log
332 | *.binlog
333 |
334 | # NVidia Nsight GPU debugger configuration file
335 | *.nvuser
336 |
337 | # MFractors (Xamarin productivity tool) working folder
338 | .mfractor/
339 |
340 | # Local History for Visual Studio
341 | .localhistory/
342 |
343 | # BeatPulse healthcheck temp database
344 | healthchecksdb
345 |
346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
347 | MigrationBackup/
348 |
349 | # Ionide (cross platform F# VS Code tools) working folder
350 | .ionide/
351 |
--------------------------------------------------------------------------------
/Aptacode.Geometry.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.1.32210.238
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Geometry", "Geometry\Geometry.csproj", "{58F7181D-CAAB-4FA7-A142-459992E700E2}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "Tests\Tests.csproj", "{40711C6F-9A32-486C-8D58-C9BF09B2575C}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmarks", "Benchmarks\Benchmarks.csproj", "{76A3A35B-5558-4E03-A9D5-05379369834B}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo", "Demo\Demo.csproj", "{3BE6653B-FC7E-4F0F-9384-4103E72020EC}"
13 | EndProject
14 | Global
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|Any CPU = Debug|Any CPU
17 | Release|Any CPU = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
20 | {58F7181D-CAAB-4FA7-A142-459992E700E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {58F7181D-CAAB-4FA7-A142-459992E700E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {58F7181D-CAAB-4FA7-A142-459992E700E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {58F7181D-CAAB-4FA7-A142-459992E700E2}.Release|Any CPU.Build.0 = Release|Any CPU
24 | {40711C6F-9A32-486C-8D58-C9BF09B2575C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {40711C6F-9A32-486C-8D58-C9BF09B2575C}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {40711C6F-9A32-486C-8D58-C9BF09B2575C}.Release|Any CPU.ActiveCfg = Release|Any CPU
27 | {40711C6F-9A32-486C-8D58-C9BF09B2575C}.Release|Any CPU.Build.0 = Release|Any CPU
28 | {76A3A35B-5558-4E03-A9D5-05379369834B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29 | {76A3A35B-5558-4E03-A9D5-05379369834B}.Debug|Any CPU.Build.0 = Debug|Any CPU
30 | {76A3A35B-5558-4E03-A9D5-05379369834B}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {76A3A35B-5558-4E03-A9D5-05379369834B}.Release|Any CPU.Build.0 = Release|Any CPU
32 | {3BE6653B-FC7E-4F0F-9384-4103E72020EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33 | {3BE6653B-FC7E-4F0F-9384-4103E72020EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
34 | {3BE6653B-FC7E-4F0F-9384-4103E72020EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
35 | {3BE6653B-FC7E-4F0F-9384-4103E72020EC}.Release|Any CPU.Build.0 = Release|Any CPU
36 | EndGlobalSection
37 | GlobalSection(SolutionProperties) = preSolution
38 | HideSolutionNode = FALSE
39 | EndGlobalSection
40 | GlobalSection(ExtensibilityGlobals) = postSolution
41 | SolutionGuid = {54627E93-4B2B-44E1-9997-31DDDB558358}
42 | EndGlobalSection
43 | EndGlobal
44 |
--------------------------------------------------------------------------------
/Benchmarks/Benchmarks.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | Logo.ico
7 | High performance .net 7 graphics library for Blazor
8 | Benchmarks
9 | Aptacode.Geometry.Benchmarks
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Benchmarks/CreationBenchmark.cs:
--------------------------------------------------------------------------------
1 | using Aptacode.Geometry.Primitives;
2 | using BenchmarkDotNet.Attributes;
3 | using BenchmarkDotNet.Exporters.Csv;
4 |
5 | namespace Aptacode.Geometry.Benchmarks;
6 |
7 | [JsonExporterAttribute.Full]
8 | [CsvMeasurementsExporter]
9 | [CsvExporter(CsvSeparator.Comma)]
10 | [HtmlExporter]
11 | [MarkdownExporterAttribute.GitHub]
12 | public class CreationBenchmark
13 | {
14 | [Benchmark]
15 | public Primitive CreatePoint()
16 | {
17 | return new Point(0, 0);
18 | }
19 |
20 | [Benchmark]
21 | public Primitive CreateEllipse()
22 | {
23 | return new Circle(0, 0, 2);
24 | }
25 |
26 | [Benchmark]
27 | public Primitive CreatePolygon()
28 | {
29 | return new Polygon(0, 0, 0, 1, 1, 1, 1, 0);
30 | }
31 |
32 | [Benchmark]
33 | public Primitive CreatePolyline()
34 | {
35 | return new PolyLine(0, 0, 0, 1, 1, 1, 1, 0);
36 | }
37 | }
--------------------------------------------------------------------------------
/Benchmarks/EllipseCollisionBenchmarks.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Numerics;
3 | using Aptacode.Geometry.Primitives;
4 | using BenchmarkDotNet.Attributes;
5 | using BenchmarkDotNet.Exporters.Csv;
6 |
7 | namespace Aptacode.Geometry.Benchmarks;
8 |
9 | [JsonExporterAttribute.Full]
10 | [CsvMeasurementsExporter]
11 | [CsvExporter(CsvSeparator.Comma)]
12 | [HtmlExporter]
13 | [MarkdownExporterAttribute.GitHub]
14 | public class EllipseCollisionBenchmarks
15 | {
16 | public IEnumerable
9 |
10 | [](https://github.com/Aptacode/Geometry/actions/workflows/test.yml)
11 | [](https://aptacode.github.io/Geometry/)
12 | [](https://www.codacy.com/gh/Aptacode/Geometry/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Aptacode/Geometry&utm_campaign=Badge_Grade)
13 | [](https://github.com/Aptacode/Geometry/blob/main/CODE_METRICS.md)
14 | [](https://www.nuget.org/packages/Aptacode.Geometry/)
15 | 
16 | [](https://opensource.org/licenses/MIT)
17 |
18 |
--------------------------------------------------------------------------------
/Resources/Images/Banner.afdesign:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aptacode/Geometry/b61a409286a742fa6a8f705535e2ccb1842a6cf9/Resources/Images/Banner.afdesign
--------------------------------------------------------------------------------
/Resources/Images/Banner.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aptacode/Geometry/b61a409286a742fa6a8f705535e2ccb1842a6cf9/Resources/Images/Banner.jpg
--------------------------------------------------------------------------------
/Resources/Images/Banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aptacode/Geometry/b61a409286a742fa6a8f705535e2ccb1842a6cf9/Resources/Images/Banner.png
--------------------------------------------------------------------------------
/Resources/Images/Logo.afdesign:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aptacode/Geometry/b61a409286a742fa6a8f705535e2ccb1842a6cf9/Resources/Images/Logo.afdesign
--------------------------------------------------------------------------------
/Resources/Images/Logo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aptacode/Geometry/b61a409286a742fa6a8f705535e2ccb1842a6cf9/Resources/Images/Logo.ico
--------------------------------------------------------------------------------
/Resources/Images/Logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aptacode/Geometry/b61a409286a742fa6a8f705535e2ccb1842a6cf9/Resources/Images/Logo.jpg
--------------------------------------------------------------------------------
/Resources/Images/Logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aptacode/Geometry/b61a409286a742fa6a8f705535e2ccb1842a6cf9/Resources/Images/Logo.png
--------------------------------------------------------------------------------
/Tests/Collision/CircleHelper_Tests.cs:
--------------------------------------------------------------------------------
1 | using System.Numerics;
2 | using Aptacode.Geometry.Collision;
3 | using Aptacode.Geometry.Primitives;
4 | using Aptacode.Geometry.Tests.Collision.PointCollisionTestData;
5 | using Aptacode.Geometry.Tests.Collision.PrimitiveCollisionTestData;
6 | using Xunit;
7 | using Xunit.Abstractions;
8 | using Xunit.Sdk;
9 |
10 | namespace Aptacode.Geometry.Tests.Collision;
11 |
12 | public class CircleHelper_Tests
13 | {
14 | private readonly ITestOutputHelper testOutputHelper;
15 |
16 | public CircleHelper_Tests(ITestOutputHelper testOutputHelper)
17 | {
18 | this.testOutputHelper = testOutputHelper;
19 | }
20 |
21 | [Theory]
22 | [InlineData(0,2,2,0,0,0,1,false)]//Fully outside
23 | [InlineData(0,2,2,0,0,0,10,true)]//Fully inside
24 | [InlineData(1,-1,-1,1,0,0,1,true)]//Touching
25 | [InlineData(0,0,2,0,0,0,1,true)]//Partially inside
26 | public void CircleLineSegmentIntersection(float aX, float aY, float bX, float bY, float cX, float cY, float cR, bool shouldIntersect)
27 | {
28 | //Arrange
29 | var a = new Vector2(aX, aY);
30 | var b = new Vector2(bX, bY);
31 | var c = new Vector2(cX, cY);
32 |
33 | //Act
34 | var intersects = (a,b).IntersectsCircle(c, cR);
35 |
36 | //Assert
37 | Assert.Equal(shouldIntersect, intersects);
38 | }
39 | }
--------------------------------------------------------------------------------
/Tests/Collision/Collision_Tests.cs:
--------------------------------------------------------------------------------
1 | using System.Numerics;
2 | using Aptacode.Geometry.Primitives;
3 | using Aptacode.Geometry.Tests.Collision.PointCollisionTestData;
4 | using Aptacode.Geometry.Tests.Collision.PrimitiveCollisionTestData;
5 | using Xunit;
6 | using Xunit.Abstractions;
7 | using Xunit.Sdk;
8 |
9 | namespace Aptacode.Geometry.Tests.Collision;
10 |
11 | public class Collision_Tests
12 | {
13 | private readonly ITestOutputHelper testOutputHelper;
14 |
15 | public Collision_Tests(ITestOutputHelper testOutputHelper)
16 | {
17 | this.testOutputHelper = testOutputHelper;
18 | }
19 |
20 | [Theory]
21 | [ClassData(typeof(PointPrimitiveCollisionTestDataGenerator))]
22 | [ClassData(typeof(EllipsePrimitiveCollisionTestDataGenerator))]
23 | [ClassData(typeof(PolygonPrimitiveCollisionTestDataGenerator))]
24 | [ClassData(typeof(PolylinePrimitiveCollisionTestDataGenerator))]
25 | public void PrimitiveCollidesWithPrimitive(Primitive p1, Primitive p2, bool collides)
26 | {
27 | //Arrange
28 | testOutputHelper.WriteLine($"{p1} - {p2}: {collides}");
29 | //Act
30 | var collidesWithPrimitiveResult = p1.CollidesWithPrimitive(p2);
31 | var collidesWithResult = p2 switch
32 | {
33 | Point primitive => p1.CollidesWith(primitive),
34 | Circle primitive => p1.CollidesWith(primitive),
35 | Polygon primitive => p1.CollidesWith(primitive),
36 | PolyLine primitive => p1.CollidesWith(primitive),
37 | _ => false
38 | };
39 |
40 |
41 | //Assert
42 | Assert.Equal(collides, collidesWithPrimitiveResult);
43 | Assert.Equal(collides, collidesWithResult);
44 | }
45 |
46 | [Theory]
47 | [ClassData(typeof(PointVector2CollisionTestDataGenerator))]
48 | [ClassData(typeof(EllipseVector2CollisionTestDataGenerator))]
49 | [ClassData(typeof(PolygonVector2CollisionTestDataGenerator))]
50 | [ClassData(typeof(PolylineVector2CollisionTestDataGenerator))]
51 | public void PrimitiveCollidesWithVector2(Primitive p1, Vector2 p2, bool collides)
52 | {
53 | //Arrange
54 | testOutputHelper.WriteLine($"{p1} - ({p2.X},{p2.Y}): {collides}");
55 |
56 | //Act
57 | var sut = p1.CollidesWith(p2);
58 |
59 | //Assert
60 | Assert.Equal(collides, sut);
61 | }
62 | }
--------------------------------------------------------------------------------
/Tests/Collision/PointCollisionTestData/EllipseVector2CollisionTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Numerics;
5 | using Aptacode.Geometry.Primitives;
6 |
7 | namespace Aptacode.Geometry.Tests.Collision.PointCollisionTestData;
8 |
9 | public class EllipseVector2CollisionTestDataGenerator : IEnumerable
10 | {
11 | private readonly List _data = new()
12 | {
13 | //Ellipse
14 | new object[] { new Circle(0, 0, 10), Vector2.One, true },
15 | new object[] { new Circle(0, 0, 10), new Vector2(20, 20), false },
16 | new object[] { new Circle(Vector2.Zero, 1), new Vector2(0, 0), true },
17 | new object[] { new Circle(Vector2.Zero, 1), new Vector2(0, 1), true },
18 | new object[] { new Circle(Vector2.Zero, 1), new Vector2(1, 1), false },
19 | new object[] { new Circle(Vector2.Zero, 1), new Vector2(0, 1), true },
20 | new object[] { new Circle(Vector2.Zero, 1), new Vector2(1, -1), false },
21 | new object[] { new Circle(Vector2.Zero, 1), new Vector2(0, -1), true },
22 | new object[] { new Circle(Vector2.Zero, 1), new Vector2(-1, -1), false },
23 | new object[] { new Circle(Vector2.Zero, 1), new Vector2(-1, 0), true },
24 | new object[] { new Circle(Vector2.Zero, 1), new Vector2(-1, 1), false },
25 | new object[] { new Circle(Vector2.Zero, 1), new Vector2(0, 0), true },
26 | new object[] { new Circle(Vector2.Zero, 1), new Vector2(0, 1), true },
27 | new object[] { new Circle(Vector2.Zero, 1), new Vector2(1, 1), false },
28 | new object[] { new Circle(Vector2.Zero, 1), new Vector2(0, 1), true },
29 | new object[] { new Circle(Vector2.Zero, 1), new Vector2(1, -1), false },
30 | new object[] { new Circle(Vector2.Zero, 1), new Vector2(0, -1), true },
31 | new object[] { new Circle(Vector2.Zero, 1), new Vector2(-1, -1), false },
32 | new object[] { new Circle(Vector2.Zero, 1), new Vector2(-1, 0), true },
33 | new object[] { new Circle(Vector2.Zero, 1), new Vector2(-1, 1), false },
34 | };
35 |
36 | public IEnumerator GetEnumerator()
37 | {
38 | return _data.GetEnumerator();
39 | }
40 |
41 | IEnumerator IEnumerable.GetEnumerator()
42 | {
43 | return GetEnumerator();
44 | }
45 | }
--------------------------------------------------------------------------------
/Tests/Collision/PointCollisionTestData/PointVector2CollisionTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using System.Numerics;
4 | using Aptacode.Geometry.Primitives;
5 |
6 | namespace Aptacode.Geometry.Tests.Collision.PointCollisionTestData;
7 |
8 | public class PointVector2CollisionTestDataGenerator : IEnumerable
9 | {
10 | private readonly List _data = new()
11 | {
12 | //Point
13 | new object[] { new Point(0, 0), new Vector2(0, 0), true },
14 | new object[] { new Point(0, 0), new Vector2(0, 1), false },
15 | new object[] { new Point(0, 0), new Vector2(1, 0), false },
16 | new object[] { new Point(0, 0), new Vector2(1, 1), false }
17 | };
18 |
19 | public IEnumerator GetEnumerator()
20 | {
21 | return _data.GetEnumerator();
22 | }
23 |
24 | IEnumerator IEnumerable.GetEnumerator()
25 | {
26 | return GetEnumerator();
27 | }
28 | }
--------------------------------------------------------------------------------
/Tests/Collision/PointCollisionTestData/PolygonVector2CollisionTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using System.Numerics;
4 | using Aptacode.Geometry.Primitives;
5 |
6 | namespace Aptacode.Geometry.Tests.Collision.PointCollisionTestData;
7 |
8 | public class PolygonVector2CollisionTestDataGenerator : IEnumerable
9 | {
10 | private readonly List _data = new()
11 | {
12 | //Polygon
13 | new object[] { Polygon.Rectangle.FromTwoPoints(Vector2.Zero, Vector2.One), Vector2.Zero, true },
14 | new object[] { Polygon.Rectangle.FromTwoPoints(Vector2.Zero, Vector2.One), new Vector2(2, 2), false },
15 | new object[] { Polygon.Rectangle.FromTwoPoints(new Vector2(10, 10), new Vector2(20, 20)), Vector2.Zero, false },
16 | new object[]
17 | { new Polygon(new Vector2(10, 10), new Vector2(20, 20), new Vector2(20, 10)), Vector2.Zero, false },
18 | new object[]
19 | {
20 | new Polygon(new Vector2(10, 10), new Vector2(20, 20), new Vector2(20, 10)), new Vector2(14, 15), false
21 | },
22 | new object[]
23 | {
24 | new Polygon(new Vector2(10, 10), new Vector2(20, 20), new Vector2(20, 10)), new Vector2(15, 15), true
25 | },
26 | new object[]
27 | {
28 | new Polygon(new Vector2(10, 10), new Vector2(20, 20), new Vector2(20, 10)), new Vector2(16, 15), true
29 | },
30 | new object[]
31 | {
32 | new Polygon(new Vector2(10, 10), new Vector2(20, 20), new Vector2(20, 10)), new Vector2(19, 15), true
33 | },
34 | new object[]
35 | {
36 | new Polygon(new Vector2(10, 10), new Vector2(20, 20), new Vector2(20, 10)), new Vector2(20, 15), true
37 | },
38 | new object[]
39 | {
40 | new Polygon(new Vector2(10, 10), new Vector2(20, 20), new Vector2(20, 10)), new Vector2(21, 15), false
41 | },
42 | new object[]
43 | {
44 | new Polygon(new Vector2(10, 10), new Vector2(20, 20), new Vector2(20, 10)), new Vector2(15, 9), false
45 | },
46 | new object[]
47 | {
48 | new Polygon(new Vector2(10, 10), new Vector2(20, 20), new Vector2(20, 10)), new Vector2(15, 10), true
49 | },
50 | new object[]
51 | { new Polygon(new Vector2(10, 10), new Vector2(20, 20), new Vector2(20, 10)), new Vector2(15, 11), true }
52 | };
53 |
54 | public IEnumerator GetEnumerator()
55 | {
56 | return _data.GetEnumerator();
57 | }
58 |
59 | IEnumerator IEnumerable.GetEnumerator()
60 | {
61 | return GetEnumerator();
62 | }
63 | }
--------------------------------------------------------------------------------
/Tests/Collision/PointCollisionTestData/PolylineVector2CollisionTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using System.Numerics;
4 | using Aptacode.Geometry.Primitives;
5 |
6 | namespace Aptacode.Geometry.Tests.Collision.PointCollisionTestData;
7 |
8 | public class PolylineVector2CollisionTestDataGenerator : IEnumerable
9 | {
10 | private readonly List _data = new()
11 | {
12 | //PolyLine
13 | new object[] { new PolyLine(0, 0, 10, 10), new Vector2(-1, -1), false },
14 | new object[] { new PolyLine(0, 0, 10, 10), new Vector2(0, -1), false },
15 | new object[] { new PolyLine(0, 0, 10, 10), new Vector2(-1, 0), false },
16 | new object[] { new PolyLine(0, 0, 10, 10), new Vector2(0, 0), true },
17 | new object[] { new PolyLine(0, 0, 10, 10), new Vector2(5, 5), true },
18 | new object[] { new PolyLine(0, 0, 10, 10), new Vector2(10, 10), true },
19 | new object[] { new PolyLine(0, 0, 10, 10), new Vector2(11, 11), false },
20 | new object[] { new PolyLine(0, 0, 10, 10), new Vector2(10, 11), false },
21 | new object[] { new PolyLine(0, 0, 10, 10), new Vector2(11, 10), false },
22 | new object[] { new PolyLine(0, 10, 10, 0, 0, -10, -10, 0), Vector2.Zero, false },
23 | new object[] { new PolyLine(0, 10, 10, 0, 0, -10, -10, 0), Vector2.One, false }
24 | };
25 |
26 | public IEnumerator GetEnumerator()
27 | {
28 | return _data.GetEnumerator();
29 | }
30 |
31 | IEnumerator IEnumerable.GetEnumerator()
32 | {
33 | return GetEnumerator();
34 | }
35 | }
--------------------------------------------------------------------------------
/Tests/Collision/PrimitiveCollisionTestData/EllipsePrimitiveCollisionTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Numerics;
5 | using Aptacode.Geometry.Primitives;
6 |
7 | namespace Aptacode.Geometry.Tests.Collision.PrimitiveCollisionTestData;
8 |
9 | public class EllipsePrimitiveCollisionTestDataGenerator : IEnumerable
10 | {
11 | private readonly List _data = new()
12 | {
13 | //Ellipse Ellipse
14 | new object[]
15 | { new Circle(10, 10, 10), new Circle(20, 20, 10), true }, //circle intersection
16 | new object[]
17 | { new Circle(10, 10, 10), new Circle(10, 10, 5), true }, //circle containment
18 | new object[]
19 | {
20 | new Circle(Vector2.Zero, 1), new Circle(new Vector2(2, 2), 1), false
21 | },
22 | new object[] { new Circle(Vector2.Zero, 1), new Point(new Vector2(2, 2)), false },
23 | new object[]
24 | {
25 | new Circle(Vector2.Zero, 1), PolyLine.Create(new Vector2(2, 2), new Vector2(3, 3)),
26 | false
27 | },
28 |
29 | new object[]
30 | { new Circle(new Vector2(10), 1), PolyLine.Create(new Vector2(10, 0), new Vector2(10, 20)), true },
31 | new object[]
32 | { new Circle(new Vector2(10), 1), PolyLine.Create(new Vector2(9, 0), new Vector2(9, 20)), true },
33 | new object[]
34 | { new Circle(new Vector2(10), 1), PolyLine.Create(new Vector2(11, 0), new Vector2(11, 20)), true },
35 | new object[]
36 | { new Circle(new Vector2(10), 1), PolyLine.Create(new Vector2(8, 0), new Vector2(8, 20)), false },
37 | new object[]
38 | { new Circle(new Vector2(10), 1), PolyLine.Create(new Vector2(12, 0), new Vector2(12, 20)), false },
39 | new object[]
40 | { new Circle(new Vector2(10), 1), PolyLine.Create(new Vector2(0, 10), new Vector2(20, 10)), true },
41 | new object[]
42 | { new Circle(new Vector2(10), 1), PolyLine.Create(new Vector2(0, 9), new Vector2(20, 9)), true },
43 | new object[]
44 | { new Circle(new Vector2(10), 1), PolyLine.Create(new Vector2(0, 11), new Vector2(20, 11)), true },
45 | new object[]
46 | { new Circle(new Vector2(10), 1), PolyLine.Create(new Vector2(0, 8), new Vector2(20, 8)), false },
47 | new object[]
48 | { new Circle(new Vector2(10), 1), PolyLine.Create(new Vector2(0, 12), new Vector2(20, 12)), false },
49 | new object[]
50 | {
51 | new Circle(Vector2.Zero, 1),
52 | Polygon.Rectangle.FromTwoPoints(new Vector2(2, 2), Vector2.One), false
53 | }
54 | };
55 |
56 | public IEnumerator GetEnumerator()
57 | {
58 | return _data.GetEnumerator();
59 | }
60 |
61 | IEnumerator IEnumerable.GetEnumerator()
62 | {
63 | return GetEnumerator();
64 | }
65 | }
--------------------------------------------------------------------------------
/Tests/Collision/PrimitiveCollisionTestData/PointPrimitiveCollisionTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Numerics;
5 | using Aptacode.Geometry.Primitives;
6 |
7 | namespace Aptacode.Geometry.Tests.Collision.PrimitiveCollisionTestData;
8 |
9 | public class PointPrimitiveCollisionTestDataGenerator : IEnumerable
10 | {
11 | private readonly List _data = new()
12 | {
13 | //Point Point
14 | new object[] { new Point(0, 0), new Point(0, 0), true },
15 | new object[] { new Point(0, 0), new Point(1, 1), false },
16 |
17 | //Ellipse Point
18 | new object[] { new Point(new Vector2(2, 2)), new Circle(Vector2.Zero,1), false }
19 | };
20 |
21 | public IEnumerator GetEnumerator()
22 | {
23 | return _data.GetEnumerator();
24 | }
25 |
26 | IEnumerator IEnumerable.GetEnumerator()
27 | {
28 | return GetEnumerator();
29 | }
30 | }
--------------------------------------------------------------------------------
/Tests/Collision/PrimitiveCollisionTestData/PolygonPrimitiveCollisionTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Numerics;
5 | using Aptacode.Geometry.Primitives;
6 |
7 | namespace Aptacode.Geometry.Tests.Collision.PrimitiveCollisionTestData;
8 |
9 | public class PolygonPrimitiveCollisionTestDataGenerator : IEnumerable
10 | {
11 | private readonly List _data = new()
12 | {
13 | //Circle Polygon
14 | new object[]
15 | {
16 | new Circle(Vector2.Zero, 1),
17 | Polygon.Rectangle.FromTwoPoints(new Vector2(2, 2), Vector2.One), false
18 | },
19 |
20 | //PolyLine Polygon
21 | new object[]
22 | {
23 | Polygon.Rectangle.FromTwoPoints(Vector2.Zero, Vector2.One),
24 | Polygon.Rectangle.FromTwoPoints(Vector2.One, new Vector2(2, 2)), true
25 | },
26 |
27 | //PolyLine Polygon
28 | new object[]
29 | {
30 | Polygon.Rectangle.FromTwoPoints(Vector2.Zero, Vector2.One),
31 | PolyLine.Create(Vector2.Zero, Vector2.One), true
32 | }
33 | };
34 |
35 | public IEnumerator GetEnumerator()
36 | {
37 | return _data.GetEnumerator();
38 | }
39 |
40 | IEnumerator IEnumerable.GetEnumerator()
41 | {
42 | return GetEnumerator();
43 | }
44 | }
--------------------------------------------------------------------------------
/Tests/Collision/PrimitiveCollisionTestData/PolylinePrimitiveCollisionTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using System.Numerics;
4 | using Aptacode.Geometry.Primitives;
5 |
6 | namespace Aptacode.Geometry.Tests.Collision.PrimitiveCollisionTestData;
7 |
8 | public class PolylinePrimitiveCollisionTestDataGenerator : IEnumerable
9 | {
10 | private readonly List _data = new()
11 | {
12 | //Circle PolyLine
13 | new object[]
14 | {
15 | new Circle(Vector2.Zero, 1), PolyLine.Create(new Vector2(2, 2), new Vector2(3, 3)),
16 | false
17 | },
18 |
19 | //Polyline PolyLine
20 | new object[]
21 | { PolyLine.Create(Vector2.Zero, Vector2.One), PolyLine.Create(Vector2.One, new Vector2(2, 2)), true },
22 | new object[]
23 | {
24 | PolyLine.Create(Vector2.Zero, new Vector2(10, 10)),
25 | PolyLine.Create(new Vector2(10, 0), new Vector2(0, 10)), true
26 | },
27 | new object[]
28 | {
29 | PolyLine.Create(Vector2.Zero, Vector2.One), PolyLine.Create(new Vector2(2, 2), new Vector2(3, 3)), false
30 | }
31 | };
32 |
33 | public IEnumerator GetEnumerator()
34 | {
35 | return _data.GetEnumerator();
36 | }
37 |
38 | IEnumerator IEnumerable.GetEnumerator()
39 | {
40 | return GetEnumerator();
41 | }
42 | }
--------------------------------------------------------------------------------
/Tests/Logo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aptacode/Geometry/b61a409286a742fa6a8f705535e2ccb1842a6cf9/Tests/Logo.ico
--------------------------------------------------------------------------------
/Tests/Primitives/Creation/EllipseCreationTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | //using System.Collections;
2 | //using System.Collections.Generic;
3 | //using Aptacode.Geometry.Primitives;
4 |
5 | //namespace Aptacode.Geometry.Tests.Primitives.Creation;
6 |
7 | //public class EllipseCreationTestDataGenerator : IEnumerable
8 | //{
9 | // private readonly List _data = new()
10 | // {
11 | // //Ellipse
12 | // new object[] { Ellipse.Zero, Vertices.VertexArray.Create(0, 0) },
13 | // new object[] { Ellipse.Unit, Vertices.VertexArray.Create(0, 0) }
14 | // };
15 |
16 | // public IEnumerator GetEnumerator()
17 | // {
18 | // return _data.GetEnumerator();
19 | // }
20 |
21 | // IEnumerator IEnumerable.GetEnumerator()
22 | // {
23 | // return GetEnumerator();
24 | // }
25 | //}
--------------------------------------------------------------------------------
/Tests/Primitives/Creation/PointCreationTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | //using System.Collections;
2 | //using System.Collections.Generic;
3 | //using System.Numerics;
4 | //using Aptacode.Geometry.Primitives;
5 |
6 | //namespace Aptacode.Geometry.Tests.Primitives.Creation;
7 |
8 | //public class PointCreationTestDataGenerator : IEnumerable
9 | //{
10 | // private readonly List _data = new()
11 | // {
12 | // new object[] { Point.Zero, Vertices.VertexArray.Create(0, 0) },
13 | // new object[] { Point.Unit, Vertices.VertexArray.Create(1, 1) },
14 | // new object[] { Point.Create(0, 0), Vertices.VertexArray.Create(0, 0) },
15 | // new object[] { Point.Create(new Vector2(0, 0)), Vertices.VertexArray.Create(0, 0) }
16 | // };
17 |
18 | // public IEnumerator GetEnumerator()
19 | // {
20 | // return _data.GetEnumerator();
21 | // }
22 |
23 | // IEnumerator IEnumerable.GetEnumerator()
24 | // {
25 | // return GetEnumerator();
26 | // }
27 | //}
--------------------------------------------------------------------------------
/Tests/Primitives/Creation/PolygonCreationTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | //using System.Collections;
2 | //using System.Collections.Generic;
3 | //using System.Numerics;
4 | //using Aptacode.Geometry.Primitives;
5 |
6 | //namespace Aptacode.Geometry.Tests.Primitives.Creation;
7 |
8 | //public class PolygonCreationTestDataGenerator : IEnumerable
9 | //{
10 | // private readonly List _data = new()
11 | // {
12 | // new object[]
13 | // {
14 | // Polygon.Rectangle.FromTwoPoints(Vector2.Zero, Vector2.One),
15 | // Vertices.VertexArray.Create(0, 0, 0, 1, 1, 1, 1, 0)
16 | // },
17 | // new object[]
18 | // {
19 | // Polygon.Create(Vector2.Zero, Vector2.One, new Vector2(1, 0)), Vertices.VertexArray.Create(0, 0, 1, 1, 1, 0)
20 | // }
21 | // };
22 |
23 | // public IEnumerator GetEnumerator()
24 | // {
25 | // return _data.GetEnumerator();
26 | // }
27 |
28 | // IEnumerator IEnumerable.GetEnumerator()
29 | // {
30 | // return GetEnumerator();
31 | // }
32 | //}
--------------------------------------------------------------------------------
/Tests/Primitives/Creation/PolylineCreationTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | //using System.Collections;
2 | //using System.Collections.Generic;
3 | //using Aptacode.Geometry.Primitives;
4 |
5 | //namespace Aptacode.Geometry.Tests.Primitives.Creation;
6 |
7 | //public class PolylineCreationTestDataGenerator : IEnumerable
8 | //{
9 | // private readonly List _data = new()
10 | // {
11 | // new object[] { PolyLine.Zero, Vertices.VertexArray.Create(0, 0, 0, 0) },
12 | // new object[] { PolyLine.Create(0, 0, 1, 1, 2, 2), Vertices.VertexArray.Create(0, 0, 1, 1, 2, 2) }
13 | // };
14 |
15 | // public IEnumerator GetEnumerator()
16 | // {
17 | // return _data.GetEnumerator();
18 | // }
19 |
20 | // IEnumerator IEnumerable.GetEnumerator()
21 | // {
22 | // return GetEnumerator();
23 | // }
24 | //}
--------------------------------------------------------------------------------
/Tests/Primitives/Creation/PrimitiveCreationTests.cs:
--------------------------------------------------------------------------------
1 | using Aptacode.Geometry.Primitives;
2 | using System.Numerics;
3 | using Xunit;
4 |
5 | namespace Aptacode.Geometry.Tests.Primitives.Creation;
6 |
7 | public class PrimitiveCreationTests
8 | {
9 | //[Theory]
10 | //[ClassData(typeof(PointCreationTestDataGenerator))]
11 | //[ClassData(typeof(EllipseCreationTestDataGenerator))]
12 | //[ClassData(typeof(PolygonCreationTestDataGenerator))]
13 | //[ClassData(typeof(PolylineCreationTestDataGenerator))]
14 | //public void PrimitiveCreation(Primitive primitive, Vector2[] expected)
15 | //{
16 | // //Arrange
17 | // //Act
18 | // //Assert
19 | // Assert.Equal(expected, primitive.Vertices);
20 | //}
21 | }
--------------------------------------------------------------------------------
/Tests/Primitives/Equality/EllipseEqualityTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using Aptacode.Geometry.Primitives;
4 |
5 | namespace Aptacode.Geometry.Tests.Primitives.Equality;
6 |
7 | public class EllipseEqualityTestDataGenerator : IEnumerable
8 | {
9 | private readonly List _data = new()
10 | {
11 | new object[] { new Circle(0, 0, 1), new Circle(0, 0, 1), true },
12 | new object[] { new Circle(0, 0, 1), new Circle(1, 1, 1), false },
13 | new object[] { new Circle(0, 0, 1), new Circle(0, 0, 2), false },
14 | };
15 |
16 | public IEnumerator GetEnumerator()
17 | {
18 | return _data.GetEnumerator();
19 | }
20 |
21 | IEnumerator IEnumerable.GetEnumerator()
22 | {
23 | return GetEnumerator();
24 | }
25 | }
--------------------------------------------------------------------------------
/Tests/Primitives/Equality/PointEqualityTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using System.Numerics;
4 | using Aptacode.Geometry.Primitives;
5 |
6 | namespace Aptacode.Geometry.Tests.Primitives.Equality;
7 |
8 | public class PointEqualityTestDataGenerator : IEnumerable
9 | {
10 | private readonly List _data = new()
11 | {
12 | new object[] { Point.Zero, Point.Zero, true },
13 | new object[] { Point.Unit, Point.Unit, true },
14 | new object[] { new Point(2, 2), new Point(2, 2), true },
15 | new object[] { Point.Unit, Point.Zero, false },
16 | new object[] { Point.Zero, Circle.Unit, false },
17 | new object[] { Point.Zero, Polygon.Rectangle.FromTwoPoints(Vector2.Zero, Vector2.One), false },
18 | new object[] { Point.Zero, PolyLine.Create(Vector2.Zero, Vector2.One), false },
19 | new object[] { Point.Zero, null, false },
20 | };
21 |
22 | public IEnumerator GetEnumerator()
23 | {
24 | return _data.GetEnumerator();
25 | }
26 |
27 | IEnumerator IEnumerable.GetEnumerator()
28 | {
29 | return GetEnumerator();
30 | }
31 | }
--------------------------------------------------------------------------------
/Tests/Primitives/Equality/PolygonEqualityTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using Aptacode.Geometry.Primitives;
4 |
5 | namespace Aptacode.Geometry.Tests.Primitives.Equality;
6 |
7 | public class PolygonEqualityTestDataGenerator : IEnumerable
8 | {
9 | private readonly List _data = new()
10 | {
11 | new object[] { new Polygon(0, 0, 1, 1, 0, 1), new Polygon(0, 0, 1, 1, 0, 1), true },
12 | new object[] { new Polygon(0, 0, 1, 1, 0, 1), new Polygon(0, 0, 1, 1, 0, 2), false },
13 | new object[] { new Polygon(0, 0, 1, 1, 0, 1), new Polygon(0, 0, 1, 1, 0, 1, 0, 2), false },
14 | new object[] { new Polygon(0, 0, 1, 1, 0, 1), null, false },
15 | };
16 |
17 | public IEnumerator GetEnumerator()
18 | {
19 | return _data.GetEnumerator();
20 | }
21 |
22 | IEnumerator IEnumerable.GetEnumerator()
23 | {
24 | return GetEnumerator();
25 | }
26 | }
--------------------------------------------------------------------------------
/Tests/Primitives/Equality/PolylineEqualityTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using Aptacode.Geometry.Primitives;
4 |
5 | namespace Aptacode.Geometry.Tests.Primitives.Equality;
6 |
7 | public class PolylineEqualityTestDataGenerator : IEnumerable
8 | {
9 | private readonly List _data = new()
10 | {
11 | new object[] { new PolyLine(0, 0, 1, 1), new PolyLine(0, 0, 1, 1), true },
12 | new object[] { new PolyLine(0, 0, 1, 1), new PolyLine(0, 0, 1, 0), false },
13 | new object[] { new PolyLine(0, 0, 1, 1), new PolyLine(0, 0, 1, 1, 2, 2), false },
14 | new object[] { new PolyLine(0, 0, 1, 1), null, false },
15 | };
16 |
17 | public IEnumerator GetEnumerator()
18 | {
19 | return _data.GetEnumerator();
20 | }
21 |
22 | IEnumerator IEnumerable.GetEnumerator()
23 | {
24 | return GetEnumerator();
25 | }
26 | }
--------------------------------------------------------------------------------
/Tests/Primitives/Equality/PrimitiveEqualityTests.cs:
--------------------------------------------------------------------------------
1 | using Aptacode.Geometry.Primitives;
2 | using Xunit;
3 |
4 | namespace Aptacode.Geometry.Tests.Primitives.Equality;
5 |
6 | public class PrimitiveEqualityTests
7 | {
8 | [Theory]
9 | [ClassData(typeof(PointEqualityTestDataGenerator))]
10 | [ClassData(typeof(EllipseEqualityTestDataGenerator))]
11 | [ClassData(typeof(PolygonEqualityTestDataGenerator))]
12 | [ClassData(typeof(PolylineEqualityTestDataGenerator))]
13 | public void Primitive_Equality(Primitive p1, Primitive p2, bool areEqual)
14 | {
15 | //Arrange
16 | //Act
17 |
18 | //Assert
19 | if (p1 != null)
20 | {
21 | var equalsMethodResult = p1.AreEqual(p2);
22 | Assert.Equal(areEqual, equalsMethodResult);
23 | }
24 | else
25 | {
26 | var equalsMethodResult = p2.AreEqual(p1);
27 | Assert.Equal(areEqual, equalsMethodResult);
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/Tests/Primitives/ToString/EllipseToStringTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using Aptacode.Geometry.Primitives;
4 |
5 | namespace Aptacode.Geometry.Tests.Primitives.ToString;
6 |
7 | public class EllipseToStringTestDataGenerator : IEnumerable
8 | {
9 | private readonly List _data = new()
10 | {
11 | new object[] { new Circle(0, 0, 1), "Circle (0,0), 1" }
12 | };
13 |
14 | public IEnumerator GetEnumerator()
15 | {
16 | return _data.GetEnumerator();
17 | }
18 |
19 | IEnumerator IEnumerable.GetEnumerator()
20 | {
21 | return GetEnumerator();
22 | }
23 | }
--------------------------------------------------------------------------------
/Tests/Primitives/ToString/PointToStringTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using Aptacode.Geometry.Primitives;
4 |
5 | namespace Aptacode.Geometry.Tests.Primitives.ToString;
6 |
7 | public class PointToStringTestDataGenerator : IEnumerable
8 | {
9 | private readonly List _data = new()
10 | {
11 | new object[] { Point.Zero, "Point (0,0)" },
12 | new object[] { Point.Unit, "Point (1,1)" },
13 | new object[] { new Point(3, 5), "Point (3,5)" }
14 | };
15 |
16 | public IEnumerator GetEnumerator()
17 | {
18 | return _data.GetEnumerator();
19 | }
20 |
21 | IEnumerator IEnumerable.GetEnumerator()
22 | {
23 | return GetEnumerator();
24 | }
25 | }
--------------------------------------------------------------------------------
/Tests/Primitives/ToString/PolygonToStringTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using Aptacode.Geometry.Primitives;
4 |
5 | namespace Aptacode.Geometry.Tests.Primitives.ToString;
6 |
7 | public class PolygonToStringTestDataGenerator : IEnumerable
8 | {
9 | private readonly List _data = new()
10 | {
11 | new object[] { new Polygon(0, 0, 1, 1, 0, 1), "Polygon (0,0), (1,1), (0,1)" }
12 | };
13 |
14 | public IEnumerator GetEnumerator()
15 | {
16 | return _data.GetEnumerator();
17 | }
18 |
19 | IEnumerator IEnumerable.GetEnumerator()
20 | {
21 | return GetEnumerator();
22 | }
23 | }
--------------------------------------------------------------------------------
/Tests/Primitives/ToString/PolylineToStringTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using Aptacode.Geometry.Primitives;
4 |
5 | namespace Aptacode.Geometry.Tests.Primitives.ToString;
6 |
7 | public class PolylineToStringTestDataGenerator : IEnumerable
8 | {
9 | private readonly List _data = new()
10 | {
11 | new object[] { PolyLine.Zero, "PolyLine (0,0), (0,0)" },
12 | new object[] { new PolyLine(0, 0, 1, 1), "PolyLine (0,0), (1,1)" }
13 | };
14 |
15 | public IEnumerator GetEnumerator()
16 | {
17 | return _data.GetEnumerator();
18 | }
19 |
20 | IEnumerator IEnumerable.GetEnumerator()
21 | {
22 | return GetEnumerator();
23 | }
24 | }
--------------------------------------------------------------------------------
/Tests/Primitives/ToString/PrimitiveToStringTests.cs:
--------------------------------------------------------------------------------
1 | using Aptacode.Geometry.Primitives;
2 | using Xunit;
3 |
4 | namespace Aptacode.Geometry.Tests.Primitives.ToString;
5 |
6 | public class PrimitiveToStringTests
7 | {
8 | [Theory]
9 | [ClassData(typeof(PointToStringTestDataGenerator))]
10 | [ClassData(typeof(EllipseToStringTestDataGenerator))]
11 | [ClassData(typeof(PolygonToStringTestDataGenerator))]
12 | [ClassData(typeof(PolylineToStringTestDataGenerator))]
13 | public void PrimitiveToStringTest(Primitive p1, string expected)
14 | {
15 | //Arrange
16 | //Act
17 | var toString = p1.ToString();
18 |
19 | //Assert
20 | Assert.Equal(expected, toString);
21 | }
22 | }
--------------------------------------------------------------------------------
/Tests/Primitives/Transformation/PrimitiveTransformationTests.cs:
--------------------------------------------------------------------------------
1 | using System.Numerics;
2 | using Aptacode.Geometry.Primitives;
3 | using Aptacode.Geometry.Tests.Primitives.Transformation.Scale;
4 | using Aptacode.Geometry.Tests.Primitives.Transformation.Translate;
5 | using Xunit;
6 | using Xunit.Abstractions;
7 |
8 | namespace Aptacode.Geometry.Tests.Primitives.Transformation;
9 |
10 | public class PrimitiveTransformationTests
11 | {
12 | private readonly ITestOutputHelper testOutput;
13 |
14 | public PrimitiveTransformationTests(ITestOutputHelper testOutput)
15 | {
16 | this.testOutput = testOutput;
17 | }
18 | [Theory]
19 | [ClassData(typeof(PointTranslationTestDataGenerator))]
20 | [ClassData(typeof(EllipseTranslationTestDataGenerator))]
21 | [ClassData(typeof(PolygonTranslationTestDataGenerator))]
22 | [ClassData(typeof(PolylineTranslationTestDataGenerator))]
23 | public void Primitive_Translation(Primitive p1, Vector2 delta, Primitive expected)
24 | {
25 | //Arrange
26 | testOutput.WriteLine($"{p1} + ({delta.X},{delta.Y}) => {expected}");
27 |
28 | //Act
29 | p1.Translate(delta);
30 |
31 | //Assert
32 | Assert.True(expected.AreEqual(p1));
33 | }
34 |
35 | [Theory]
36 | [ClassData(typeof(PointCenterScaleTestDataGenerator))]
37 | [ClassData(typeof(EllipseCenterScaleTestDataGenerator))]
38 | [ClassData(typeof(PolygonCenterScaleTestDataGenerator))]
39 | [ClassData(typeof(PolylineCenterScaleTestDataGenerator))]
40 | public void Primitive_CenterScale(Primitive p1, Vector2 delta, Primitive expected)
41 | {
42 | //Arrange
43 | testOutput.WriteLine($"{p1} + ({delta.X},{delta.Y}) => {expected}");
44 |
45 | //Act
46 | var actual = p1.ScaleAboutCenter(delta);
47 |
48 | testOutput.WriteLine($"Actual: {actual}");
49 |
50 | //Assert
51 | Assert.True(expected.AreEqual(p1));
52 | }
53 | }
--------------------------------------------------------------------------------
/Tests/Primitives/Transformation/Scale/EllipseCenterScaleTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using System.Numerics;
4 | using Aptacode.Geometry.Primitives;
5 |
6 | namespace Aptacode.Geometry.Tests.Primitives.Transformation.Scale;
7 |
8 | public class EllipseCenterScaleTestDataGenerator : IEnumerable
9 | {
10 | private readonly List _data = new()
11 | {
12 | new object[] { new Circle(Vector2.Zero, 1), Vector2.One, new Circle(Vector2.Zero, 1) },
13 | };
14 |
15 | public IEnumerator GetEnumerator()
16 | {
17 | return _data.GetEnumerator();
18 | }
19 |
20 | IEnumerator IEnumerable.GetEnumerator()
21 | {
22 | return GetEnumerator();
23 | }
24 | }
--------------------------------------------------------------------------------
/Tests/Primitives/Transformation/Scale/PointCenterScaleTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using System.Numerics;
4 | using Aptacode.Geometry.Primitives;
5 |
6 | namespace Aptacode.Geometry.Tests.Primitives.Transformation.Scale;
7 |
8 | public class PointCenterScaleTestDataGenerator : IEnumerable
9 | {
10 | private readonly List _data = new()
11 | {
12 | new object[] { Point.Zero, Vector2.Zero, Point.Zero },
13 | new object[] { Point.Zero, Vector2.One, Point.Zero },
14 | new object[] { Point.Zero, new Vector2(2), Point.Zero }
15 | };
16 |
17 | public IEnumerator GetEnumerator()
18 | {
19 | return _data.GetEnumerator();
20 | }
21 |
22 | IEnumerator IEnumerable.GetEnumerator()
23 | {
24 | return GetEnumerator();
25 | }
26 | }
--------------------------------------------------------------------------------
/Tests/Primitives/Transformation/Scale/PolygonCenterScaleTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using System.Numerics;
4 | using Aptacode.Geometry.Primitives;
5 |
6 | namespace Aptacode.Geometry.Tests.Primitives.Transformation.Scale;
7 |
8 | public class PolygonCenterScaleTestDataGenerator : IEnumerable
9 | {
10 | private readonly List _data = new()
11 | {
12 | new object[]
13 | {
14 | Polygon.Rectangle.FromTwoPoints(Vector2.Zero, Vector2.One),
15 | Vector2.One,
16 | Polygon.Rectangle.FromTwoPoints(Vector2.Zero, Vector2.One)
17 | },
18 | new object[]
19 | {
20 | Polygon.Rectangle.FromTwoPoints(Vector2.Zero, Vector2.One),
21 | new Vector2(2),
22 | Polygon.Rectangle.FromTwoPoints(new Vector2(-0.5f, -0.5f), new Vector2(1.5f, 1.5f))
23 | }
24 | };
25 |
26 | public IEnumerator GetEnumerator()
27 | {
28 | return _data.GetEnumerator();
29 | }
30 |
31 | IEnumerator IEnumerable.GetEnumerator()
32 | {
33 | return GetEnumerator();
34 | }
35 | }
--------------------------------------------------------------------------------
/Tests/Primitives/Transformation/Scale/PolylineCenterScaleTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using System.Numerics;
4 | using Aptacode.Geometry.Primitives;
5 |
6 | namespace Aptacode.Geometry.Tests.Primitives.Transformation.Scale;
7 |
8 | public class PolylineCenterScaleTestDataGenerator : IEnumerable
9 | {
10 | private readonly List _data = new()
11 | {
12 | new object[]
13 | {
14 | PolyLine.Create(Vector2.Zero, Vector2.One),
15 | Vector2.One,
16 | PolyLine.Create(Vector2.Zero, Vector2.One)
17 | },
18 | new object[]
19 | {
20 | PolyLine.Create(Vector2.Zero, Vector2.One),
21 | new Vector2(2),
22 | PolyLine.Create(new Vector2(-0.5f, -0.5f), new Vector2(1.5f, 1.5f))
23 | }
24 | };
25 |
26 | public IEnumerator GetEnumerator()
27 | {
28 | return _data.GetEnumerator();
29 | }
30 |
31 | IEnumerator IEnumerable.GetEnumerator()
32 | {
33 | return GetEnumerator();
34 | }
35 | }
--------------------------------------------------------------------------------
/Tests/Primitives/Transformation/Translate/EllipseTranslationTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using System.Numerics;
4 | using Aptacode.Geometry.Primitives;
5 |
6 | namespace Aptacode.Geometry.Tests.Primitives.Transformation.Translate;
7 |
8 | public class EllipseTranslationTestDataGenerator : IEnumerable
9 | {
10 | private readonly List _data = new()
11 | {
12 | new object[] { new Circle(Vector2.Zero, 1), Vector2.One, new Circle(Vector2.One, 1) },
13 | new object[] { new Circle(Vector2.Zero, 1), Vector2.Zero, new Circle(Vector2.Zero, 1) }
14 | };
15 |
16 | public IEnumerator GetEnumerator()
17 | {
18 | return _data.GetEnumerator();
19 | }
20 |
21 | IEnumerator IEnumerable.GetEnumerator()
22 | {
23 | return GetEnumerator();
24 | }
25 | }
--------------------------------------------------------------------------------
/Tests/Primitives/Transformation/Translate/PointTranslationTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using System.Numerics;
4 | using Aptacode.Geometry.Primitives;
5 |
6 | namespace Aptacode.Geometry.Tests.Primitives.Transformation.Translate;
7 |
8 | public class PointTranslationTestDataGenerator : IEnumerable
9 | {
10 | private readonly List _data = new()
11 | {
12 | new object[] { Point.Zero, Vector2.One, Point.Unit },
13 | new object[] { Point.Zero, Vector2.Zero, Point.Zero }
14 | };
15 |
16 | public IEnumerator GetEnumerator()
17 | {
18 | return _data.GetEnumerator();
19 | }
20 |
21 | IEnumerator IEnumerable.GetEnumerator()
22 | {
23 | return GetEnumerator();
24 | }
25 | }
--------------------------------------------------------------------------------
/Tests/Primitives/Transformation/Translate/PolygonTranslationTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using System.Numerics;
4 | using Aptacode.Geometry.Primitives;
5 |
6 | namespace Aptacode.Geometry.Tests.Primitives.Transformation.Translate;
7 |
8 | public class PolygonTranslationTestDataGenerator : IEnumerable
9 | {
10 | private readonly List _data = new()
11 | {
12 | new object[]
13 | {
14 | Polygon.Rectangle.FromTwoPoints(Vector2.Zero, Vector2.One), Vector2.One,
15 | Polygon.Rectangle.FromTwoPoints(Vector2.One, new Vector2(2, 2))
16 | },
17 | new object[]
18 | {
19 | Polygon.Rectangle.FromTwoPoints(Vector2.Zero, Vector2.One), Vector2.Zero,
20 | Polygon.Rectangle.FromTwoPoints(Vector2.Zero, Vector2.One)
21 | }
22 | };
23 |
24 | public IEnumerator GetEnumerator()
25 | {
26 | return _data.GetEnumerator();
27 | }
28 |
29 | IEnumerator IEnumerable.GetEnumerator()
30 | {
31 | return GetEnumerator();
32 | }
33 | }
--------------------------------------------------------------------------------
/Tests/Primitives/Transformation/Translate/PolylineTranslationTestDataGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using System.Numerics;
4 | using Aptacode.Geometry.Primitives;
5 |
6 | namespace Aptacode.Geometry.Tests.Primitives.Transformation.Translate;
7 |
8 | public class PolylineTranslationTestDataGenerator : IEnumerable
9 | {
10 | private readonly List _data = new()
11 | {
12 | new object[]
13 | {
14 | PolyLine.Create(Vector2.Zero, Vector2.One), Vector2.One, PolyLine.Create(Vector2.One, new Vector2(2, 2))
15 | },
16 | new object[]
17 | { PolyLine.Create(Vector2.Zero, Vector2.One), Vector2.Zero, PolyLine.Create(Vector2.Zero, Vector2.One) }
18 | };
19 |
20 | public IEnumerator GetEnumerator()
21 | {
22 | return _data.GetEnumerator();
23 | }
24 |
25 | IEnumerator IEnumerable.GetEnumerator()
26 | {
27 | return GetEnumerator();
28 | }
29 | }
--------------------------------------------------------------------------------
/Tests/Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | false
6 | Logo.ico
7 | Aptacode.Geometry.Tests
8 | Aptacode.Geometry.Tests
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | runtime; build; native; contentfiles; analyzers; buildtransitive
17 | all
18 |
19 |
20 | runtime; build; native; contentfiles; analyzers; buildtransitive
21 | all
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/Tests/UnitTests.cs:
--------------------------------------------------------------------------------
1 | using System.Numerics;
2 | using Aptacode.Geometry.Collision;
3 | using Aptacode.Geometry.Primitives;
4 | using Aptacode.Geometry.Utilities;
5 | using Xunit;
6 |
7 | namespace Aptacode.Geometry.Tests;
8 |
9 | public class UnitTests
10 | {
11 | [Fact]
12 | public void Perp_Test()
13 | {
14 | var a = new Vector2(6, 12);
15 | var b = a.Perp();
16 |
17 | Assert.Equal(new Vector2(12, -6), b);
18 | }
19 |
20 | [Fact]
21 | public void PerpDotXVectorCrossTest()
22 | {
23 | var a = new Vector2(6, 12);
24 | var b = new Vector2(12, 6);
25 |
26 | var perpDot = a.PerpDot(b);
27 | var cross = a.VectorCross(b);
28 |
29 | Assert.True(perpDot == -cross);
30 | }
31 |
32 | [Fact]
33 | public void newLineSegmentIntersection_Test()
34 | {
35 | var A1 = new Vector2(10, 10);
36 | var A2 = new Vector2(20, 10);
37 |
38 | var B1 = new Vector2(15, 10);
39 | var B2 = new Vector2(15, 15);
40 |
41 | Assert.True((A1, A2).Intersects((B1, B2)));
42 | }
43 | }
--------------------------------------------------------------------------------
/development-azure-pipelines.yml:
--------------------------------------------------------------------------------
1 | # Starter pipeline
2 | # Start with a minimal pipeline that you can customize to build and deploy your code.
3 | # Add steps that build, run tests, deploy, and more:
4 | # https://aka.ms/yaml
5 |
6 | trigger:
7 | - Development
8 |
9 | pool:
10 | vmImage: 'windows-latest'
11 |
12 | variables:
13 | solution: '**/*.sln'
14 | buildPlatform: 'Any CPU'
15 | buildConfiguration: 'Release'
16 | project: '**/Geometry.csproj'
17 | NUGET_PACKAGES: $(Pipeline.Workspace)/.nuget/packages
18 | steps:
19 |
20 | - task: UseDotNet@2
21 | displayName: 'Use .NET 5'
22 | inputs:
23 | version: 5.x
24 |
25 | - task: DotNetCoreCLI@2
26 | displayName: 'Build'
27 | inputs:
28 | command: 'build'
29 | arguments: '--configuration $(buildConfiguration)'
30 | projects: '$(project)'
31 |
32 | - task: DotNetCoreCLI@2
33 | displayName: "Pack"
34 | inputs:
35 | command: 'pack'
36 | arguments: '--configuration $(buildConfiguration)'
37 | packagesToPack: '$(project)'
38 | nobuild: true
39 | versioningScheme: 'byPrereleaseNumber'
40 | majorVersion: '1'
41 | minorVersion: '0'
42 | patchVersion: '6'
43 |
44 | - task: NuGetCommand@2
45 | displayName: 'Push'
46 | inputs:
47 | command: 'push'
48 | packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
49 | nuGetFeedType: 'external'
50 | publishFeedCredentials: 'Nuget.org'
51 | allowPackageConflicts: true
--------------------------------------------------------------------------------
/production-azure-pipelines.yml:
--------------------------------------------------------------------------------
1 | # Starter pipeline
2 | # Start with a minimal pipeline that you can customize to build and deploy your code.
3 | # Add steps that build, run tests, deploy, and more:
4 | # https://aka.ms/yaml
5 |
6 | trigger:
7 | - Production
8 |
9 | pool:
10 | vmImage: 'windows-latest'
11 |
12 | variables:
13 | solution: '**/*.sln'
14 | buildPlatform: 'Any CPU'
15 | buildConfiguration: 'Release'
16 | project: '**/Geometry.csproj'
17 | NUGET_PACKAGES: $(Pipeline.Workspace)/.nuget/packages
18 | steps:
19 |
20 | - task: UseDotNet@2
21 | displayName: 'Use .NET 5'
22 | inputs:
23 | version: 5.x
24 |
25 | - task: DotNetCoreCLI@2
26 | displayName: 'Build'
27 | inputs:
28 | command: 'build'
29 | arguments: '--configuration $(buildConfiguration)'
30 | projects: '$(project)'
31 |
32 | - task: DotNetCoreCLI@2
33 | displayName: "Pack"
34 | inputs:
35 | command: 'pack'
36 | arguments: '--configuration $(buildConfiguration)'
37 | packagesToPack: '$(project)'
38 | nobuild: true
39 |
40 | - task: NuGetCommand@2
41 | displayName: 'Push'
42 | inputs:
43 | command: 'push'
44 | packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
45 | nuGetFeedType: 'external'
46 | publishFeedCredentials: 'Nuget.org'
47 | allowPackageConflicts: true
--------------------------------------------------------------------------------