CapyKit/Docs/_site/api/CapyKit.Helpers.CalculationHelper.html

586 lines
19 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 ">
<meta name="description" content="Static class providing helper methods for various calculations.">
<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 &quot;{query}&quot;">
<meta name="loc:searchNoResults" content="No results for &quot;{query}&quot;">
<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="ManagedReference">
<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="CapyKit.Helpers.CalculationHelper">
<h1 id="CapyKit_Helpers_CalculationHelper" data-uid="CapyKit.Helpers.CalculationHelper" class="text-break">
Class CalculationHelper
</h1>
<div class="facts text-secondary">
<dl><dt>Namespace</dt><dd><a class="xref" href="CapyKit.html">CapyKit</a>.<a class="xref" href="CapyKit.Helpers.html">Helpers</a></dd></dl>
<dl><dt>Assembly</dt><dd>CapyKit.dll</dd></dl>
</div>
<div class="markdown summary"><p>Static class providing helper methods for various calculations.</p>
</div>
<div class="markdown conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static class CalculationHelper</code></pre>
</div>
<dl class="typelist inheritance">
<dt>Inheritance</dt>
<dd>
<div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div>
<div><span class="xref">CalculationHelper</span></div>
</dd>
</dl>
<dl class="typelist inheritedMembers">
<dt>Inherited Members</dt>
<dd>
<div>
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object)</a>
</div>
<div>
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object, object)</a>
</div>
<div>
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a>
</div>
<div>
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>
</div>
<div>
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone">object.MemberwiseClone()</a>
</div>
<div>
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object, object)</a>
</div>
<div>
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>
</div>
</dd></dl>
<h2 class="section" id="fields">Fields
</h2>
<h3 id="CapyKit_Helpers_CalculationHelper_EARTH_RADIUS_KILOMETERS" data-uid="CapyKit.Helpers.CalculationHelper.EARTH_RADIUS_KILOMETERS">
EARTH_RADIUS_KILOMETERS
</h3>
<div class="markdown level1 summary"><p>The earth's radius in kilometers.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public const int EARTH_RADIUS_KILOMETERS = 6371</code></pre>
</div>
<h4 class="section">Field Value</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></dt>
<dd></dd>
</dl>
<h3 id="CapyKit_Helpers_CalculationHelper_MILES_PER_KILOMETER" data-uid="CapyKit.Helpers.CalculationHelper.MILES_PER_KILOMETER">
MILES_PER_KILOMETER
</h3>
<div class="markdown level1 summary"><p>Ratio of miles per kilometer .</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public const double MILES_PER_KILOMETER = 0.621371</code></pre>
</div>
<h4 class="section">Field Value</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></dt>
<dd></dd>
</dl>
<h2 class="section" id="methods">Methods
</h2>
<a id="CapyKit_Helpers_CalculationHelper_CalculateHash_" data-uid="CapyKit.Helpers.CalculationHelper.CalculateHash*"></a>
<h3 id="CapyKit_Helpers_CalculationHelper_CalculateHash_System_String_" data-uid="CapyKit.Helpers.CalculationHelper.CalculateHash(System.String)">
CalculateHash(string)
</h3>
<div class="markdown level1 summary"><p>Calculates the hash of a given string using an <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.security.cryptography.md5">MD5</a> value as the first 32 bits.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static int CalculateHash(string str)</code></pre>
</div>
<h4 class="section">Parameters</h4>
<dl class="parameters">
<dt><code>str</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
<dd><p>The string to be hashed.</p>
</dd>
</dl>
<h4 class="section">Returns</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></dt>
<dd><p>The calculated hash.</p>
</dd>
</dl>
<h4 class="section" id="CapyKit_Helpers_CalculationHelper_CalculateHash_System_String__remarks">Remarks</h4>
<div class="markdown level1 remarks"><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>
</div>
<a id="CapyKit_Helpers_CalculationHelper_CalculateHexHash_" data-uid="CapyKit.Helpers.CalculationHelper.CalculateHexHash*"></a>
<h3 id="CapyKit_Helpers_CalculationHelper_CalculateHexHash_System_String_" data-uid="CapyKit.Helpers.CalculationHelper.CalculateHexHash(System.String)">
CalculateHexHash(string)
</h3>
<div class="markdown level1 summary"><p>Calculates the hexadecimal hash.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static string CalculateHexHash(string str)</code></pre>
</div>
<h4 class="section">Parameters</h4>
<dl class="parameters">
<dt><code>str</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
<dd><p>The string to be hashed.</p>
</dd>
</dl>
<h4 class="section">Returns</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
<dd><p>The calculated 16 character hexadecimal hash.</p>
</dd>
</dl>
<a id="CapyKit_Helpers_CalculationHelper_DegreesToRadians_" data-uid="CapyKit.Helpers.CalculationHelper.DegreesToRadians*"></a>
<h3 id="CapyKit_Helpers_CalculationHelper_DegreesToRadians_System_Double_" data-uid="CapyKit.Helpers.CalculationHelper.DegreesToRadians(System.Double)">
DegreesToRadians(double)
</h3>
<div class="markdown level1 summary"><p>Convers degrees to radians.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static double DegreesToRadians(double degrees)</code></pre>
</div>
<h4 class="section">Parameters</h4>
<dl class="parameters">
<dt><code>degrees</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></dt>
<dd><p>The degree value.</p>
</dd>
</dl>
<h4 class="section">Returns</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></dt>
<dd><p>The value as radians.</p>
</dd>
</dl>
<a id="CapyKit_Helpers_CalculationHelper_GetDistance_" data-uid="CapyKit.Helpers.CalculationHelper.GetDistance*"></a>
<h3 id="CapyKit_Helpers_CalculationHelper_GetDistance_System_Decimal_System_Decimal_System_Decimal_System_Decimal_CapyKit_Enumerations_MeasurementSystem_" data-uid="CapyKit.Helpers.CalculationHelper.GetDistance(System.Decimal,System.Decimal,System.Decimal,System.Decimal,CapyKit.Enumerations.MeasurementSystem)">
GetDistance(decimal, decimal, decimal, decimal, MeasurementSystem)
</h3>
<div class="markdown level1 summary"><p>Gets the distance between two points on earth using the <code>haversine</code> formula.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static decimal GetDistance(decimal latitudeOrigin, decimal longitudeOrigin, decimal latitudeDestination, decimal longitudeDestination, MeasurementSystem measurementSystem = MeasurementSystem.Imperial)</code></pre>
</div>
<h4 class="section">Parameters</h4>
<dl class="parameters">
<dt><code>latitudeOrigin</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.decimal">decimal</a></dt>
<dd><p>The latitude origin.</p>
</dd>
<dt><code>longitudeOrigin</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.decimal">decimal</a></dt>
<dd><p>The longitude origin.</p>
</dd>
<dt><code>latitudeDestination</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.decimal">decimal</a></dt>
<dd><p>The latitude destination.</p>
</dd>
<dt><code>longitudeDestination</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.decimal">decimal</a></dt>
<dd><p>The longitude destination.</p>
</dd>
<dt><code>measurementSystem</code> <a class="xref" href="CapyKit.Enumerations.MeasurementSystem.html">MeasurementSystem</a></dt>
<dd><p>(Optional) The measurement system.</p>
</dd>
</dl>
<h4 class="section">Returns</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.decimal">decimal</a></dt>
<dd><p>The distance.</p>
</dd>
</dl>
<h4 class="section" id="CapyKit_Helpers_CalculationHelper_GetDistance_System_Decimal_System_Decimal_System_Decimal_System_Decimal_CapyKit_Enumerations_MeasurementSystem__remarks">Remarks</h4>
<div class="markdown level1 remarks"><p>Uses the <a href="https://www.movable-type.co.uk/scripts/latlong.html">haversine</a> formula
to calculate the &quot;as-the-crow-flies&quot; distance between two points on earth.</p>
</div>
<dl class="typelist seealso">
<dt>See Also</dt>
<dd>
<div><a class="xref" href="CapyKit.Helpers.CalculationHelper.html#CapyKit_Helpers_CalculationHelper_GetDistance_System_Double_System_Double_System_Double_System_Double_CapyKit_Enumerations_MeasurementSystem_">GetDistance(double, double, double, double, MeasurementSystem)</a></div>
</dd>
</dl>
<a id="CapyKit_Helpers_CalculationHelper_GetDistance_" data-uid="CapyKit.Helpers.CalculationHelper.GetDistance*"></a>
<h3 id="CapyKit_Helpers_CalculationHelper_GetDistance_System_Double_System_Double_System_Double_System_Double_CapyKit_Enumerations_MeasurementSystem_" data-uid="CapyKit.Helpers.CalculationHelper.GetDistance(System.Double,System.Double,System.Double,System.Double,CapyKit.Enumerations.MeasurementSystem)">
GetDistance(double, double, double, double, MeasurementSystem)
</h3>
<div class="markdown level1 summary"><p>Gets the distance between two points on earth using the <code>haversine</code> formula.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static double GetDistance(double latitudeOrigin, double longitudeOrigin, double latitudeDestination, double longitudeDestination, MeasurementSystem measurementSystem = MeasurementSystem.Imperial)</code></pre>
</div>
<h4 class="section">Parameters</h4>
<dl class="parameters">
<dt><code>latitudeOrigin</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></dt>
<dd><p>The latitude of the origin.</p>
</dd>
<dt><code>longitudeOrigin</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></dt>
<dd><p>The longitude of the origin.</p>
</dd>
<dt><code>latitudeDestination</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></dt>
<dd><p>The latitude destination.</p>
</dd>
<dt><code>longitudeDestination</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></dt>
<dd><p>The longitude destination.</p>
</dd>
<dt><code>measurementSystem</code> <a class="xref" href="CapyKit.Enumerations.MeasurementSystem.html">MeasurementSystem</a></dt>
<dd><p>(Optional) The measurement system.</p>
</dd>
</dl>
<h4 class="section">Returns</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></dt>
<dd><p>The distance.</p>
</dd>
</dl>
<h4 class="section" id="CapyKit_Helpers_CalculationHelper_GetDistance_System_Double_System_Double_System_Double_System_Double_CapyKit_Enumerations_MeasurementSystem__remarks">Remarks</h4>
<div class="markdown level1 remarks"><p>Uses the <a href="https://www.movable-type.co.uk/scripts/latlong.html">haversine</a> formula
to calculate the &quot;as-the-crow-flies&quot; distance between two points on earth.</p>
</div>
<a id="CapyKit_Helpers_CalculationHelper_KilometersToMiles_" data-uid="CapyKit.Helpers.CalculationHelper.KilometersToMiles*"></a>
<h3 id="CapyKit_Helpers_CalculationHelper_KilometersToMiles_System_Double_" data-uid="CapyKit.Helpers.CalculationHelper.KilometersToMiles(System.Double)">
KilometersToMiles(double)
</h3>
<div class="markdown level1 summary"><p>Converts kilometers to miles.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static double KilometersToMiles(double kilometers)</code></pre>
</div>
<h4 class="section">Parameters</h4>
<dl class="parameters">
<dt><code>kilometers</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></dt>
<dd><p>The value in kilometers.</p>
</dd>
</dl>
<h4 class="section">Returns</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></dt>
<dd><p>The value in miles.</p>
</dd>
</dl>
<a id="CapyKit_Helpers_CalculationHelper_MilesToKilometers_" data-uid="CapyKit.Helpers.CalculationHelper.MilesToKilometers*"></a>
<h3 id="CapyKit_Helpers_CalculationHelper_MilesToKilometers_System_Double_" data-uid="CapyKit.Helpers.CalculationHelper.MilesToKilometers(System.Double)">
MilesToKilometers(double)
</h3>
<div class="markdown level1 summary"><p>Converts miles to kilometers.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static double MilesToKilometers(double miles)</code></pre>
</div>
<h4 class="section">Parameters</h4>
<dl class="parameters">
<dt><code>miles</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></dt>
<dd><p>The value in miles.</p>
</dd>
</dl>
<h4 class="section">Returns</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></dt>
<dd><p>The value in kilometers.</p>
</dd>
</dl>
<a id="CapyKit_Helpers_CalculationHelper_RadiansToDegrees_" data-uid="CapyKit.Helpers.CalculationHelper.RadiansToDegrees*"></a>
<h3 id="CapyKit_Helpers_CalculationHelper_RadiansToDegrees_System_Double_" data-uid="CapyKit.Helpers.CalculationHelper.RadiansToDegrees(System.Double)">
RadiansToDegrees(double)
</h3>
<div class="markdown level1 summary"><p>Converts radians to degrees.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static double RadiansToDegrees(double radians)</code></pre>
</div>
<h4 class="section">Parameters</h4>
<dl class="parameters">
<dt><code>radians</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></dt>
<dd><p>The radian value.</p>
</dd>
</dl>
<h4 class="section">Returns</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></dt>
<dd><p>The value as degrees.</p>
</dd>
</dl>
</article>
<div class="contribution d-print-none">
</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>