{"id":20596052,"url":"https://github.com/davidfig/angle","last_synced_at":"2025-07-19T13:13:36.154Z","repository":{"id":57404876,"uuid":"62429652","full_name":"davidfig/angle","owner":"davidfig","description":"Library for calculating angles in javascript","archived":false,"fork":false,"pushed_at":"2021-07-20T15:07:52.000Z","size":36,"stargazers_count":16,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T23:44:17.842Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidfig.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-02T02:13:54.000Z","updated_at":"2023-06-08T16:59:10.000Z","dependencies_parsed_at":"2022-09-26T17:01:39.141Z","dependency_job_id":null,"html_url":"https://github.com/davidfig/angle","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidfig%2Fangle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidfig%2Fangle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidfig%2Fangle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidfig%2Fangle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidfig","download_url":"https://codeload.github.com/davidfig/angle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248981259,"owners_count":21193143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T08:14:54.008Z","updated_at":"2025-04-14T23:44:22.677Z","avatar_url":"https://github.com/davidfig.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## yy-angle\nLibrary of useful functions for working with angles in javascript.\n\n## rationale\nI wanted to make my life much easier when working with angles since they usually hurt my brain.\n\n## Installation\ninclude angle.js in your project or add to your workflow\n\n    npm i yy-angle\n\n## API\n```js\n/** @constant {number} */\nconst UP = Math.PI / 2\nconst DOWN = 3 * Math.PI / 2\nconst LEFT = Math.PI\nconst RIGHT = 0\n\nconst NORTH = UP\nconst SOUTH = DOWN\nconst WEST = LEFT\nconst EAST = RIGHT\n\nconst PI_2 = Math.PI * 2\nconst PI_QUARTER = Math.PI / 4\nconst PI_HALF = Math.PI / 2\n\nexport const NORTH_WEST = (NORTH + WEST) / 2\nexport const NORTH_EAST = (NORTH + EAST) / 2\nexport const SOUTH_WEST = (SOUTH + WEST) / 2\nexport const SOUTH_EAST = (SOUTH + EAST) / 2\n\n/**\n * converts from radians to degrees (all other functions expect radians)\n * @param {number} radians\n * @return {number} degrees\n */\nfunction toDegrees(radians)\n\n/**\n * converts from degrees to radians (all other functions expect radians)\n * @param {number} degrees\n * @return {number} radians\n */\nfunction toRadians(degrees)\n\n/**\n * returns whether the target angle is between angle1 and angle2 (in radians)\n * (based on: http://stackoverflow.com/questions/11406189/determine-if-angle-lies-between-2-other-angles)\n * @param {number} target angle\n * @param {number} angle1\n * @param {number} angle2\n * @return {boolean}\n */\nfunction isAngleBetween(target, angle1, angle2)\n\n/**\n * returns +1 or -1 based on whether the difference between two angles is positive or negative (in radians)\n * @param {number} target angle\n * @param {number} source angle\n * @return {number} 1 or -1\n */\nfunction differenceAnglesSign(target, source)\n\n/**\n * returns the normalized difference between two angles (in radians)\n * @param {number} a - first angle\n * @param {number} b - second angle\n * @return {number} normalized difference between a and b\n */\nfunction differenceAngles(a, b)\n\n/**\n * returns a target angle that is the shortest way to rotate an object between start and to--may choose a negative angle\n * @param {number} start\n * @param {number} to\n * @return {number} shortest target angle\n */\nfunction shortestAngle(start, to)\n\n/**\n * returns the normalized angle (0 - PI x 2)\n * @param {number} radians\n * @return {number} normalized angle in radians\n */\nfunction normalize(radians)\n\n/**\n * returns angle between two points (in radians)\n * @param {Point} [point1] {x: x, y: y}\n * @param {Point} [point2] {x: x, y: y}\n * @param {number} [x1]\n * @param {number} [y1]\n * @param {number} [x2]\n * @param {number} [y2]\n * @return {number} angle\n */\nfunction angleTwoPoints(/* (point1, point2) OR (x1, y1, x2, y2) */)\n\n/**\n * returns distance between two points\n * @param {Point} [point1] {x: x, y: y}\n * @param {Point} [point2] {x: x, y: y}\n * @param {number} [x1]\n * @param {number} [y1]\n * @param {number} [x2]\n * @param {number} [y2]\n * @return {number} distance\n */\nfunction distanceTwoPoints(/* (point1, point2) OR (x1, y1, x2, y2) */)\n\n/**\n * returns the squared distance between two points\n * @param {Point} [point1] {x: x, y: y}\n * @param {Point} [point2] {x: x, y: y}\n * @param {number} [x1]\n * @param {number} [y1]\n * @param {number} [x2]\n * @param {number} [y2]\n * @return {number} squared distance\n */\nfunction distanceTwoPointsSquared(/* (point1, point2) OR (x1, y1, x2, y2) */)\n\n/**\n * returns the closest cardinal (N, S, E, W) to the given angle (in radians)\n * @param {number} angle\n * @return {number} closest cardinal in radians\n */\nfunction closestAngle(angle)\n\n/**\n * returns the closest cardinal w/diagonal (N, S, E, W, NE, NW, SE, SW) to the given angle (in radians)\n * @param {number} angle\n * @return {number} closest cardinal in radians\n */\nexport function closestAngle2(angle: number)\n\n/**\n * checks whether angles a1 and a2 are equal (after normalizing)\n * @param {number} a1\n * @param {number} a2\n * @param {number} [wiggle] return true if the difference between the angles is \u003c= wiggle\n * @return {boolean} a1 === a2\n */\nfunction equals(a1, a2, wiggle)\n\n/**\n * return a text representation of the cardinal direction\n * @param {number} angle\n * @returns {string} UP, DOWN, LEFT, RIGHT, or NOT CARDINAL\n */\nfunction explain(angle)\n\n/**\n * returns a text representation of the closest cardinal w/diagonal (N, S, E, W, NE, NW, SE, SW) to the given angle\n * @param {number} angle\n * @return {string} NORTH, WEST, EAST, SOUTH, NORTH_EAST, NORTH_WEST, SOUTH_EAST, SOUTH_WEST\n */\nfunction explain2(angle)\n\n```\n## license\nMIT License\n(c) 2017 [YOPEY YOPEY LLC](https://yopeyopey.com/) by [David Figatner](https://twitter.com/yopey_yopey/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidfig%2Fangle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidfig%2Fangle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidfig%2Fangle/lists"}