UNPKG

@phun-ky/angle

Version:

A JavaScript function to calculate the angle between two coordinates

55 lines (54 loc) 3.11 kB
/** * @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.61 * @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 3.0.1 * @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. */ function t(t){return!function(t){return"number"==typeof t}(t)}function e(t){return void 0===t}const r=(r,n,o,f,u=!0)=>{if(e(r)||e(n)||e(o)||e(f))throw new SyntaxError("Missing input for `angle`");if(t(r)||t(n)||t(o)||t(f))throw TypeError(`Parameters for \`angle\` do not have the required type. Requires number! Got: ${typeof r} ${typeof n} ${typeof o} ${typeof f}`);const i=f-n,a=o-r;let p=Math.atan2(i,a);return p*=180/Math.PI,u&&p<0&&(p+=360),p};export{r as angle}; //# sourceMappingURL=angle.esm.js.map