@phun-ky/angle
Version:
A JavaScript function to calculate the angle between two coordinates
55 lines (54 loc) • 3.06 kB
JavaScript
/**
* @phun-ky/angle
* A JavaScript function to calculate the angle between two coordinates
* @author Alexander Vassbotn Røyne-Helgesen <alexander@phun-ky.net>
* @version 1.0.27
* @license
* Copyright (c) 2024 Alexander Vassbotn Røyne-Helgesen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**
* @phun-ky/typeof
* A set of JavaScript helper functions to check for types
* @author Alexander Vassbotn Røyne-Helgesen <alexander@phun-ky.net>
* @version 1.2.21
* @license
* Copyright (c) 2024 Alexander Vassbotn Røyne-Helgesen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
const e=e=>!(e=>"number"==typeof e)(e),t=e=>void 0===e,r=(r,o,n,a,f=!0)=>{if(t(r)||t(o)||t(n)||t(a))throw new SyntaxError("Missing input for `angle`");if(e(r)||e(o)||e(n)||e(a))throw TypeError(`Parameters for \`angle\` do not have the required type. Requires number! Got: ${typeof r} ${typeof o} ${typeof n} ${typeof a}`);const p=a-o,i=n-r;let y=Math.atan2(p,i);return y*=180/Math.PI,f&&y<0&&(y+=360),y};export{r as angle};
//# sourceMappingURL=angle.esm.js.map