240 lines
13 KiB
HTML
240 lines
13 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title> Class CalculationHelper | CapyKit Documentation </title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta name="title" content=" Class CalculationHelper | CapyKit Documentation ">
|
|
|
|
|
|
<link rel="icon" href="../favicon.ico">
|
|
<link rel="stylesheet" href="../public/docfx.min.css">
|
|
<link rel="stylesheet" href="../public/main.css">
|
|
<meta name="docfx:navrel" content="../toc.html">
|
|
<meta name="docfx:tocrel" content="../toc.html">
|
|
|
|
<meta name="docfx:rel" content="../">
|
|
|
|
|
|
|
|
<meta name="loc:inThisArticle" content="In this article">
|
|
<meta name="loc:searchResultsCount" content="{count} results for "{query}"">
|
|
<meta name="loc:searchNoResults" content="No results for "{query}"">
|
|
<meta name="loc:tocFilter" content="Filter by title">
|
|
<meta name="loc:nextArticle" content="Next">
|
|
<meta name="loc:prevArticle" content="Previous">
|
|
<meta name="loc:themeLight" content="Light">
|
|
<meta name="loc:themeDark" content="Dark">
|
|
<meta name="loc:themeAuto" content="Auto">
|
|
<meta name="loc:changeTheme" content="Change theme">
|
|
<meta name="loc:copy" content="Copy">
|
|
<meta name="loc:downloadPdf" content="Download PDF">
|
|
|
|
<script type="module" src="./../public/docfx.min.js"></script>
|
|
|
|
<script>
|
|
const theme = localStorage.getItem('theme') || 'auto'
|
|
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="">
|
|
<header class="bg-body border-bottom">
|
|
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
|
|
<div class="container-xxl flex-nowrap">
|
|
<a class="navbar-brand" href="../index.html">
|
|
<img id="logo" class="svg" src="../logo.svg" alt="CapyKit Documentation">
|
|
CapyKit Documentation
|
|
</a>
|
|
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
|
|
<i class="bi bi-three-dots"></i>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navpanel">
|
|
<div id="navbar">
|
|
<form class="search" role="search" id="search">
|
|
<i class="bi bi-search"></i>
|
|
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
</header>
|
|
|
|
<main class="container-xxl">
|
|
|
|
<div class="content">
|
|
<div class="actionbar">
|
|
|
|
<nav id="breadcrumb"></nav>
|
|
</div>
|
|
|
|
<article data-uid="">
|
|
<h1 id="CapyKit_Helpers_CalculationHelper"> Class CalculationHelper</h1>
|
|
|
|
<p>Namespace: <a href="CapyKit.Helpers.html">CapyKit.Helpers</a><br>
|
|
Assembly: CapyKit.dll</p>
|
|
<p>Static class providing helper methods for various calculations.</p>
|
|
<pre><code class="lang-csharp">public static class CalculationHelper
|
|
</code></pre>
|
|
<h4 id="inheritance">Inheritance</h4>
|
|
<p><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ←
|
|
<a href="CapyKit.Helpers.CalculationHelper.html">CalculationHelper</a></p>
|
|
<h4 id="inherited-members">Inherited Members</h4>
|
|
<p><a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object?)</a>,
|
|
<a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object?, object?)</a>,
|
|
<a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a>,
|
|
<a href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>,
|
|
<a href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone">object.MemberwiseClone()</a>,
|
|
<a href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object?, object?)</a>,
|
|
<a href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a></p>
|
|
<h4 id="extension-methods">Extension Methods</h4>
|
|
<p><a href="CapyKit.Extensions.ObjectExtensions.html#CapyKit_Extensions_ObjectExtensions_UpdateProperties_System_Object_System_Object_">ObjectExtensions.UpdateProperties(object, object)</a></p>
|
|
<h2 id="fields">Fields</h2>
|
|
<h3 id="CapyKit_Helpers_CalculationHelper_EARTH_RADIUS_KILOMETERS"> EARTH_RADIUS_KILOMETERS</h3>
|
|
<p>The earth's radius in kilometers.</p>
|
|
<pre><code class="lang-csharp">public const int EARTH_RADIUS_KILOMETERS = 6371
|
|
</code></pre>
|
|
<h4 id="field-value">Field Value</h4>
|
|
<p><a href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></p>
|
|
<h3 id="CapyKit_Helpers_CalculationHelper_MILES_PER_KILOMETER"> MILES_PER_KILOMETER</h3>
|
|
<p>Ratio of miles per kilometer .</p>
|
|
<pre><code class="lang-csharp">public const double MILES_PER_KILOMETER = 0.621371
|
|
</code></pre>
|
|
<h4 id="field-value-1">Field Value</h4>
|
|
<p><a href="https://learn.microsoft.com/dotnet/api/system.double">double</a></p>
|
|
<h2 id="methods">Methods</h2>
|
|
<h3 id="CapyKit_Helpers_CalculationHelper_CalculateHash_System_String_"> CalculateHash(string)</h3>
|
|
<p>Calculates the hash of a given string using an <span class="xref">System.Security.Cryptography.MD5</span> value as the first 32 bits.</p>
|
|
<pre><code class="lang-csharp">public static int CalculateHash(string str)
|
|
</code></pre>
|
|
<h4 id="parameters">Parameters</h4>
|
|
<p><code>str</code> <a href="https://learn.microsoft.com/dotnet/api/system.string">string</a></p>
|
|
<p>The string to be hashed.</p>
|
|
<h4 id="returns">Returns</h4>
|
|
<p><a href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></p>
|
|
<p>The calculated hash.</p>
|
|
<h4 id="remarks">Remarks</h4>
|
|
<p>This method is used for a quick and consistent hash function. It should not be considered
|
|
cryptographically sound or used in security contexts.</p>
|
|
<h3 id="CapyKit_Helpers_CalculationHelper_CalculateHexHash_System_String_"> CalculateHexHash(string)</h3>
|
|
<p>Calculates the hexadecimal hash.</p>
|
|
<pre><code class="lang-csharp">public static string CalculateHexHash(string str)
|
|
</code></pre>
|
|
<h4 id="parameters-1">Parameters</h4>
|
|
<p><code>str</code> <a href="https://learn.microsoft.com/dotnet/api/system.string">string</a></p>
|
|
<p>The string to be hashed.</p>
|
|
<h4 id="returns-1">Returns</h4>
|
|
<p><a href="https://learn.microsoft.com/dotnet/api/system.string">string</a></p>
|
|
<p>The calculated 16 character hexadecimal hash.</p>
|
|
<h3 id="CapyKit_Helpers_CalculationHelper_DegreesToRadians_System_Double_"> DegreesToRadians(double)</h3>
|
|
<p>Convers degrees to radians.</p>
|
|
<pre><code class="lang-csharp">public static double DegreesToRadians(double degrees)
|
|
</code></pre>
|
|
<h4 id="parameters-2">Parameters</h4>
|
|
<p><code>degrees</code> <a href="https://learn.microsoft.com/dotnet/api/system.double">double</a></p>
|
|
<p>The degree value.</p>
|
|
<h4 id="returns-2">Returns</h4>
|
|
<p><a href="https://learn.microsoft.com/dotnet/api/system.double">double</a></p>
|
|
<p>The value as radians.</p>
|
|
<h3 id="CapyKit_Helpers_CalculationHelper_GetDistance_System_Decimal_System_Decimal_System_Decimal_System_Decimal_CapyKit_Enumerations_MeasurementSystem_"> GetDistance(decimal, decimal, decimal, decimal, MeasurementSystem)</h3>
|
|
<p>Gets the distance between two points on earth using the <code>haversine</code> formula.</p>
|
|
<pre><code class="lang-csharp">public static decimal GetDistance(decimal latitudeOrigin, decimal longitudeOrigin, decimal latitudeDestination, decimal longitudeDestination, MeasurementSystem measurementSystem = MeasurementSystem.Imperial)
|
|
</code></pre>
|
|
<h4 id="parameters-3">Parameters</h4>
|
|
<p><code>latitudeOrigin</code> <a href="https://learn.microsoft.com/dotnet/api/system.decimal">decimal</a></p>
|
|
<p>The latitude origin.</p>
|
|
<p><code>longitudeOrigin</code> <a href="https://learn.microsoft.com/dotnet/api/system.decimal">decimal</a></p>
|
|
<p>The longitude origin.</p>
|
|
<p><code>latitudeDestination</code> <a href="https://learn.microsoft.com/dotnet/api/system.decimal">decimal</a></p>
|
|
<p>The latitude destination.</p>
|
|
<p><code>longitudeDestination</code> <a href="https://learn.microsoft.com/dotnet/api/system.decimal">decimal</a></p>
|
|
<p>The longitude destination.</p>
|
|
<p><code>measurementSystem</code> <a href="CapyKit.Enumerations.MeasurementSystem.html">MeasurementSystem</a></p>
|
|
<p>(Optional) The measurement system.</p>
|
|
<h4 id="returns-3">Returns</h4>
|
|
<p><a href="https://learn.microsoft.com/dotnet/api/system.decimal">decimal</a></p>
|
|
<p>The distance.</p>
|
|
<h4 id="remarks-1">Remarks</h4>
|
|
<p>Uses the <a href="https://www.movable-type.co.uk/scripts/latlong.html">haversine</a> formula
|
|
to calculate the "as-the-crow-flies" distance between two points on earth.</p>
|
|
<h4 id="see-also">See Also</h4>
|
|
<p><a href="CapyKit.Helpers.CalculationHelper.html">CalculationHelper</a>.<a href="CapyKit.Helpers.CalculationHelper.html#CapyKit_Helpers_CalculationHelper_GetDistance_System_Double_System_Double_System_Double_System_Double_CapyKit_Enumerations_MeasurementSystem_">GetDistance</a>(<a href="https://learn.microsoft.com/dotnet/api/system.double">double</a>, <a href="https://learn.microsoft.com/dotnet/api/system.double">double</a>, <a href="https://learn.microsoft.com/dotnet/api/system.double">double</a>, <a href="https://learn.microsoft.com/dotnet/api/system.double">double</a>, <a href="CapyKit.Enumerations.MeasurementSystem.html">MeasurementSystem</a>)</p>
|
|
<h3 id="CapyKit_Helpers_CalculationHelper_GetDistance_System_Double_System_Double_System_Double_System_Double_CapyKit_Enumerations_MeasurementSystem_"> GetDistance(double, double, double, double, MeasurementSystem)</h3>
|
|
<p>Gets the distance between two points on earth using the <code>haversine</code> formula.</p>
|
|
<pre><code class="lang-csharp">public static double GetDistance(double latitudeOrigin, double longitudeOrigin, double latitudeDestination, double longitudeDestination, MeasurementSystem measurementSystem = MeasurementSystem.Imperial)
|
|
</code></pre>
|
|
<h4 id="parameters-4">Parameters</h4>
|
|
<p><code>latitudeOrigin</code> <a href="https://learn.microsoft.com/dotnet/api/system.double">double</a></p>
|
|
<p>The latitude of the origin.</p>
|
|
<p><code>longitudeOrigin</code> <a href="https://learn.microsoft.com/dotnet/api/system.double">double</a></p>
|
|
<p>The longitude of the origin.</p>
|
|
<p><code>latitudeDestination</code> <a href="https://learn.microsoft.com/dotnet/api/system.double">double</a></p>
|
|
<p>The latitude destination.</p>
|
|
<p><code>longitudeDestination</code> <a href="https://learn.microsoft.com/dotnet/api/system.double">double</a></p>
|
|
<p>The longitude destination.</p>
|
|
<p><code>measurementSystem</code> <a href="CapyKit.Enumerations.MeasurementSystem.html">MeasurementSystem</a></p>
|
|
<p>(Optional) The measurement system.</p>
|
|
<h4 id="returns-4">Returns</h4>
|
|
<p><a href="https://learn.microsoft.com/dotnet/api/system.double">double</a></p>
|
|
<p>The distance.</p>
|
|
<h4 id="remarks-2">Remarks</h4>
|
|
<p>Uses the <a href="https://www.movable-type.co.uk/scripts/latlong.html">haversine</a> formula
|
|
to calculate the "as-the-crow-flies" distance between two points on earth.</p>
|
|
<h3 id="CapyKit_Helpers_CalculationHelper_KilometersToMiles_System_Double_"> KilometersToMiles(double)</h3>
|
|
<p>Converts kilometers to miles.</p>
|
|
<pre><code class="lang-csharp">public static double KilometersToMiles(double kilometers)
|
|
</code></pre>
|
|
<h4 id="parameters-5">Parameters</h4>
|
|
<p><code>kilometers</code> <a href="https://learn.microsoft.com/dotnet/api/system.double">double</a></p>
|
|
<p>The value in kilometers.</p>
|
|
<h4 id="returns-5">Returns</h4>
|
|
<p><a href="https://learn.microsoft.com/dotnet/api/system.double">double</a></p>
|
|
<p>The value in miles.</p>
|
|
<h3 id="CapyKit_Helpers_CalculationHelper_MilesToKilometers_System_Double_"> MilesToKilometers(double)</h3>
|
|
<p>Converts miles to kilometers.</p>
|
|
<pre><code class="lang-csharp">public static double MilesToKilometers(double miles)
|
|
</code></pre>
|
|
<h4 id="parameters-6">Parameters</h4>
|
|
<p><code>miles</code> <a href="https://learn.microsoft.com/dotnet/api/system.double">double</a></p>
|
|
<p>The value in miles.</p>
|
|
<h4 id="returns-6">Returns</h4>
|
|
<p><a href="https://learn.microsoft.com/dotnet/api/system.double">double</a></p>
|
|
<p>The value in kilometers.</p>
|
|
<h3 id="CapyKit_Helpers_CalculationHelper_RadiansToDegrees_System_Double_"> RadiansToDegrees(double)</h3>
|
|
<p>Converts radians to degrees.</p>
|
|
<pre><code class="lang-csharp">public static double RadiansToDegrees(double radians)
|
|
</code></pre>
|
|
<h4 id="parameters-7">Parameters</h4>
|
|
<p><code>radians</code> <a href="https://learn.microsoft.com/dotnet/api/system.double">double</a></p>
|
|
<p>The radian value.</p>
|
|
<h4 id="returns-7">Returns</h4>
|
|
<p><a href="https://learn.microsoft.com/dotnet/api/system.double">double</a></p>
|
|
<p>The value as degrees.</p>
|
|
|
|
</article>
|
|
|
|
<div class="contribution d-print-none">
|
|
</div>
|
|
|
|
<div class="next-article d-print-none border-top" id="nextArticle"></div>
|
|
|
|
</div>
|
|
|
|
<div class="affix">
|
|
<nav id="affix"></nav>
|
|
</div>
|
|
</main>
|
|
|
|
<div class="container-xxl search-results" id="search-results"></div>
|
|
|
|
<footer class="border-top text-secondary">
|
|
<div class="container-xxl">
|
|
<div class="flex-fill">
|
|
<span>Made with <a href="https://dotnet.github.io/docfx">docfx</a></span>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
</body>
|
|
</html>
|