Class CalculationHelper

Namespace
CapyKit.Helpers
Assembly
CapyKit.dll

Static class providing helper methods for various calculations.

public static class CalculationHelper
Inheritance
CalculationHelper
Inherited Members

Fields

EARTH_RADIUS_KILOMETERS

The earth's radius in kilometers.

public const int EARTH_RADIUS_KILOMETERS = 6371

Field Value

int

MILES_PER_KILOMETER

Ratio of miles per kilometer .

public const double MILES_PER_KILOMETER = 0.621371

Field Value

double

Methods

CalculateHash(string)

Calculates the hash of a given string using an MD5 value as the first 32 bits.

public static int CalculateHash(string str)

Parameters

str string

The string to be hashed.

Returns

int

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

string

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

double

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

decimal

The distance.

Remarks

Uses the haversine formula to calculate the "as-the-crow-flies" distance between two points on earth.

See Also

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

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.

public static double KilometersToMiles(double kilometers)

Parameters

kilometers double

The value in kilometers.

Returns

double

The value in miles.

MilesToKilometers(double)

Converts miles to kilometers.

public static double MilesToKilometers(double miles)

Parameters

miles double

The value in miles.

Returns

double

The value in kilometers.

RadiansToDegrees(double)

Converts radians to degrees.

public static double RadiansToDegrees(double radians)

Parameters

radians double

The radian value.

Returns

double

The value as degrees.