Class CalculationHelper
Namespace: CapyKit.Helpers
Assembly: CapyKit.dll
Static class providing helper methods for various calculations.
public static class CalculationHelper
Inheritance
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Extension Methods
ObjectExtensions.UpdateProperties(object, object)
Fields
EARTH_RADIUS_KILOMETERS
The earth's radius in kilometers.
public const int EARTH_RADIUS_KILOMETERS = 6371
Field Value
MILES_PER_KILOMETER
Ratio of miles per kilometer .
public const double MILES_PER_KILOMETER = 0.621371
Field Value
Methods
CalculateHash(string)
Calculates the hash of a given string using an System.Security.Cryptography.MD5 value as the first 32 bits.
public static int CalculateHash(string str)
Parameters
str string
The string to be hashed.
Returns
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.
public static string CalculateHexHash(string str)
Parameters
str string
The string to be hashed.
Returns
The calculated 16 character hexadecimal hash.
DegreesToRadians(double)
Convers degrees to radians.
public static double DegreesToRadians(double degrees)
Parameters
degrees double
The degree value.
Returns
The value as radians.
GetDistance(decimal, decimal, decimal, decimal, MeasurementSystem)
Gets the distance between two points on earth using the haversine formula.
public static decimal GetDistance(decimal latitudeOrigin, decimal longitudeOrigin, decimal latitudeDestination, decimal longitudeDestination, MeasurementSystem measurementSystem = MeasurementSystem.Imperial)
Parameters
latitudeOrigin decimal
The latitude origin.
longitudeOrigin decimal
The longitude origin.
latitudeDestination decimal
The latitude destination.
longitudeDestination decimal
The longitude destination.
measurementSystem MeasurementSystem
(Optional) The measurement system.
Returns
The distance.
Remarks
Uses the haversine formula to calculate the "as-the-crow-flies" distance between two points on earth.
See Also
CalculationHelper.GetDistance(double, double, double, double, MeasurementSystem)
GetDistance(double, double, double, double, MeasurementSystem)
Gets the distance between two points on earth using the haversine formula.
public static double GetDistance(double latitudeOrigin, double longitudeOrigin, double latitudeDestination, double longitudeDestination, MeasurementSystem measurementSystem = MeasurementSystem.Imperial)
Parameters
latitudeOrigin double
The latitude of the origin.
longitudeOrigin double
The longitude of the origin.
latitudeDestination double
The latitude destination.
longitudeDestination double
The longitude destination.
measurementSystem MeasurementSystem
(Optional) The measurement system.
Returns
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.
public static double KilometersToMiles(double kilometers)
Parameters
kilometers double
The value in kilometers.
Returns
The value in miles.
MilesToKilometers(double)
Converts miles to kilometers.
public static double MilesToKilometers(double miles)
Parameters
miles double
The value in miles.
Returns
The value in kilometers.
RadiansToDegrees(double)
Converts radians to degrees.
public static double RadiansToDegrees(double radians)
Parameters
radians double
The radian value.
Returns
The value as degrees.