# Class CalculationHelper Namespace: [CapyKit.Helpers](CapyKit.Helpers.md) Assembly: CapyKit.dll Static class providing helper methods for various calculations. ```csharp public static class CalculationHelper ``` #### Inheritance [object](https://learn.microsoft.com/dotnet/api/system.object) ← [CalculationHelper](CapyKit.Helpers.CalculationHelper.md) #### Inherited Members [object.Equals\(object?\)](https://learn.microsoft.com/dotnet/api/system.object.equals\#system\-object\-equals\(system\-object\)), [object.Equals\(object?, object?\)](https://learn.microsoft.com/dotnet/api/system.object.equals\#system\-object\-equals\(system\-object\-system\-object\)), [object.GetHashCode\(\)](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [object.GetType\(\)](https://learn.microsoft.com/dotnet/api/system.object.gettype), [object.MemberwiseClone\(\)](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone), [object.ReferenceEquals\(object?, object?\)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [object.ToString\(\)](https://learn.microsoft.com/dotnet/api/system.object.tostring) #### Extension Methods [ObjectExtensions.UpdateProperties\(object, object\)](CapyKit.Extensions.ObjectExtensions.md\#CapyKit\_Extensions\_ObjectExtensions\_UpdateProperties\_System\_Object\_System\_Object\_) ## Fields ### EARTH\_RADIUS\_KILOMETERS The earth's radius in kilometers. ```csharp public const int EARTH_RADIUS_KILOMETERS = 6371 ``` #### Field Value [int](https://learn.microsoft.com/dotnet/api/system.int32) ### MILES\_PER\_KILOMETER Ratio of miles per kilometer . ```csharp public const double MILES_PER_KILOMETER = 0.621371 ``` #### Field Value [double](https://learn.microsoft.com/dotnet/api/system.double) ## Methods ### CalculateHash\(string\) Calculates the hash of a given string using an value as the first 32 bits. ```csharp public static int CalculateHash(string str) ``` #### Parameters `str` [string](https://learn.microsoft.com/dotnet/api/system.string) The string to be hashed. #### Returns [int](https://learn.microsoft.com/dotnet/api/system.int32) The calculated hash. #### Remarks This method is used for a quick and consistent hash function. It should not be considered cryptographically sound or used in security contexts. ### CalculateHexHash\(string\) Calculates the hexadecimal hash. ```csharp public static string CalculateHexHash(string str) ``` #### Parameters `str` [string](https://learn.microsoft.com/dotnet/api/system.string) The string to be hashed. #### Returns [string](https://learn.microsoft.com/dotnet/api/system.string) The calculated 16 character hexadecimal hash. ### DegreesToRadians\(double\) Convers degrees to radians. ```csharp public static double DegreesToRadians(double degrees) ``` #### Parameters `degrees` [double](https://learn.microsoft.com/dotnet/api/system.double) The degree value. #### Returns [double](https://learn.microsoft.com/dotnet/api/system.double) The value as radians. ### GetDistance\(decimal, decimal, decimal, decimal, MeasurementSystem\) Gets the distance between two points on earth using the haversine formula. ```csharp public static decimal GetDistance(decimal latitudeOrigin, decimal longitudeOrigin, decimal latitudeDestination, decimal longitudeDestination, MeasurementSystem measurementSystem = MeasurementSystem.Imperial) ``` #### Parameters `latitudeOrigin` [decimal](https://learn.microsoft.com/dotnet/api/system.decimal) The latitude origin. `longitudeOrigin` [decimal](https://learn.microsoft.com/dotnet/api/system.decimal) The longitude origin. `latitudeDestination` [decimal](https://learn.microsoft.com/dotnet/api/system.decimal) The latitude destination. `longitudeDestination` [decimal](https://learn.microsoft.com/dotnet/api/system.decimal) The longitude destination. `measurementSystem` [MeasurementSystem](CapyKit.Enumerations.MeasurementSystem.md) (Optional) The measurement system. #### Returns [decimal](https://learn.microsoft.com/dotnet/api/system.decimal) The distance. #### Remarks Uses the haversine formula to calculate the "as-the-crow-flies" distance between two points on earth. #### See Also [CalculationHelper](CapyKit.Helpers.CalculationHelper.md).[GetDistance](CapyKit.Helpers.CalculationHelper.md\#CapyKit\_Helpers\_CalculationHelper\_GetDistance\_System\_Double\_System\_Double\_System\_Double\_System\_Double\_CapyKit\_Enumerations\_MeasurementSystem\_)\([double](https://learn.microsoft.com/dotnet/api/system.double), [double](https://learn.microsoft.com/dotnet/api/system.double), [double](https://learn.microsoft.com/dotnet/api/system.double), [double](https://learn.microsoft.com/dotnet/api/system.double), [MeasurementSystem](CapyKit.Enumerations.MeasurementSystem.md)\) ### GetDistance\(double, double, double, double, MeasurementSystem\) Gets the distance between two points on earth using the haversine formula. ```csharp public static double GetDistance(double latitudeOrigin, double longitudeOrigin, double latitudeDestination, double longitudeDestination, MeasurementSystem measurementSystem = MeasurementSystem.Imperial) ``` #### Parameters `latitudeOrigin` [double](https://learn.microsoft.com/dotnet/api/system.double) The latitude of the origin. `longitudeOrigin` [double](https://learn.microsoft.com/dotnet/api/system.double) The longitude of the origin. `latitudeDestination` [double](https://learn.microsoft.com/dotnet/api/system.double) The latitude destination. `longitudeDestination` [double](https://learn.microsoft.com/dotnet/api/system.double) The longitude destination. `measurementSystem` [MeasurementSystem](CapyKit.Enumerations.MeasurementSystem.md) (Optional) The measurement system. #### Returns [double](https://learn.microsoft.com/dotnet/api/system.double) The distance. #### Remarks Uses the haversine formula to calculate the "as-the-crow-flies" distance between two points on earth. ### KilometersToMiles\(double\) Converts kilometers to miles. ```csharp public static double KilometersToMiles(double kilometers) ``` #### Parameters `kilometers` [double](https://learn.microsoft.com/dotnet/api/system.double) The value in kilometers. #### Returns [double](https://learn.microsoft.com/dotnet/api/system.double) The value in miles. ### MilesToKilometers\(double\) Converts miles to kilometers. ```csharp public static double MilesToKilometers(double miles) ``` #### Parameters `miles` [double](https://learn.microsoft.com/dotnet/api/system.double) The value in miles. #### Returns [double](https://learn.microsoft.com/dotnet/api/system.double) The value in kilometers. ### RadiansToDegrees\(double\) Converts radians to degrees. ```csharp public static double RadiansToDegrees(double radians) ``` #### Parameters `radians` [double](https://learn.microsoft.com/dotnet/api/system.double) The radian value. #### Returns [double](https://learn.microsoft.com/dotnet/api/system.double) The value as degrees.