CodeChops.Geometry
4.3.1
See the version list below for details.
dotnet add package CodeChops.Geometry --version 4.3.1
NuGet\Install-Package CodeChops.Geometry -Version 4.3.1
<PackageReference Include="CodeChops.Geometry" Version="4.3.1" />
paket add CodeChops.Geometry --version 4.3.1
#r "nuget: CodeChops.Geometry, 4.3.1"
// Install CodeChops.Geometry as a Cake Addin #addin nuget:?package=CodeChops.Geometry&version=4.3.1 // Install CodeChops.Geometry as a Cake Tool #tool nuget:?package=CodeChops.Geometry&version=4.3.1
Geometry
Objects and helpers to provide easy calculations of objects in 2D-space and time. These objects can be (de)serialized to/from JSON. This library extensively uses the new generic math functionality of .NET 7 so each object can contain the numeric types you prefer.
Check out CodeChops projects for more projects.
Space
Point
A 2-dimensional location value object with TNumber as type of the underlying values of X
and Y
. Contains:
- Operators to perform calculations.
- Default casts (also from/to
ValueTuple
). - Converters to convert to a different
TNumber
. - Some simple predefined calculations:
Sum()
,Multiply()
.
Line
A line holds two points: a starting point and end point. Contains:
- Casts to and from
Size
. - Converters to convert to a different
TNumber
. - Some simple predefined calculations:
Distance()
,Difference()
. - An iterator to iterate all points in the line
foreach(var point in new Line<int>((0,0), (10, 10))
Size
A 2-dimensional measurement value object with TNumber as type of the underlying values of Width
and Height
. Contains:
- Operators to perform calculations.
- Default casts (also from/to
ValueTuple
). - Converters to convert to a different
TNumber
. - Some simple predefined calculations:
Circumference()
,Area()
. - An iterator to iterate all points in the size:
GetAllPoints()
or useforeach(var point in new Size<int>(10, 10))
. - Extension to convert size to inline css.
Surface
An Euclidean plane of a specific size (and offset). Contains bound checks using the size offset.
- Some simple predefined calculations:
Circumference
,Area
. - Converters to convert to a different
TNumber
. - A way to (try to) get the address of a point on the plan.
- An iterator to iterate all points in a certain direction (in number of moments).
- An iterator to iterate all points of a line.
- An iterator to iterate all points in the dimensions.
Directions
A direction holds a point which contains the delta in X and Y. There are different types of directions. Every direction type is a value object (and therefore immutable).
FreeDirection
A direction in every possible delta point. Contains:
- An
Angle
, which also can be consumed by the constructor ofFreeDirection
. - Default casts.
- Converters to convert to a different
TNumber
. - Methods to take a (random) turn.
StrictDirection
A strongly typed direction that resides in a specific enum which holds other direction values. This object makes it easy to enumerate over the directions and search for them. No free directions can be used. Contains:
- Predefined definitions:
DiagonalDirection
EveryDirection
HorizontalDirection
OrthogonalDirection
VerticalDirection
- Default casts.
- Converters to convert to a different
TNumber
. - Converters to (try to) convert to a different StrictDirection.
- Methods to take a (random) turn using
RotationType
.
StrictDirections make use of the MagicEnums library to easily enumerate directions in one definition.
StrictDirections make use of the ImplementationDiscovery library to easily enumerate different definitions.
An example of predefined definition
DiagonalDirection
public static readonly DiagonalDirection<TNumber> NorthEast = CreatePoint( 1, -1); public static readonly DiagonalDirection<TNumber> SouthEast = CreatePoint( 1, 1); public static readonly DiagonalDirection<TNumber> SouthWest = CreatePoint(-1, 1); public static readonly DiagonalDirection<TNumber> NorthWest = CreatePoint(-1, -1);
NoDirection
A singleton object that holds a delta point of (0, 0).
Movements
Describes in what direction an object moves from a starting point, using a moment counter. There are different types of movements. Every movement type is a value object (and therefore immutable).
StraightMovement
A movement that only goes into one straight direction over its lifetime.
DynamicMovement
A movement in which the direction and (therefore the location over time) can be determined by using a formula.
NoMovement
Should be used for objects that don't move. It can still hold a direction.
MomentCounter
A moment counter helps calculating the direction and location of a moving object deterministically. The moments can be calculated over time using a TimedMomentCounter, or manual moments using ManualMomentCounter.)
TimedMomentCounter
A counter in which the moments are incremented over time, using a stopwatch.
The timer can be stopped and (re)started.
A momentsCountGetter
can be provided in order to control what order of magnitude should be used (seconds, milliseconds, etc.).
ManualMomentCounter
A counter in which the moments are incremented manually until maximum moments.
MomentCounterScope
Controls access to a moment counter in the ambient context. This way a statically shared moment counter can be accessed and controlled from the outside.
This functionality makes use of Ambient Context pattern as implemented by TheArchitectDev. See Architect.AmbientContexts.
Time
IStopwatch
Wraps a Stopwatch
in order to be able to control the stopwatch from the outside.
UnixEpochConverter
A small helper to convert DateTimes to Unix time stamps and vice versa.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net7.0
- Architect.AmbientContexts (>= 1.1.1)
- CodeChops.DomainModeling (>= 2.0.1)
- CodeChops.ImplementationDiscovery (>= 1.1.1)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 7.0.0)
- System.Collections.Immutable (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
4.10.0 | 303 | 3/20/2023 |
4.9.0 | 341 | 1/27/2023 |
4.8.0 | 312 | 1/22/2023 |
4.6.1 | 354 | 1/21/2023 |
4.6.0 | 357 | 1/21/2023 |
4.5.2 | 354 | 1/20/2023 |
4.5.1 | 340 | 1/18/2023 |
4.5.0 | 322 | 1/18/2023 |
4.4.1 | 324 | 1/18/2023 |
4.4.0 | 332 | 1/18/2023 |
4.3.2 | 331 | 1/16/2023 |
4.3.1 | 340 | 1/15/2023 |
4.3.0 | 367 | 1/11/2023 |
4.2.0 | 342 | 1/10/2023 |
4.1.1 | 354 | 1/6/2023 |
4.0.0 | 562 | 1/3/2023 |
2.4.4 | 472 | 7/11/2022 |
2.4.3 | 430 | 7/10/2022 |
2.4.2 | 444 | 7/10/2022 |
2.4.1 | 461 | 7/10/2022 |
2.4.0 | 482 | 6/23/2022 |
2.3.8 | 463 | 6/23/2022 |
2.3.7 | 463 | 6/21/2022 |
2.3.6 | 450 | 6/12/2022 |
2.3.5 | 474 | 4/19/2022 |
2.3.4 | 447 | 4/19/2022 |
2.3.3 | 462 | 4/6/2022 |
2.3.2 | 489 | 4/6/2022 |
2.3.1 | 464 | 4/6/2022 |
2.2.2 | 479 | 3/23/2022 |
2.2.1 | 451 | 3/22/2022 |
2.2.0 | 461 | 3/22/2022 |
2.1.1 | 460 | 3/22/2022 |
2.1.0 | 475 | 3/17/2022 |
2.0.1 | 487 | 3/7/2022 |
Added line direction constructor.