{"id":16131867,"url":"https://github.com/uberi/anglr","last_synced_at":"2026-03-17T17:37:25.006Z","repository":{"id":29180016,"uuid":"32710841","full_name":"Uberi/anglr","owner":"Uberi","description":"Planar angle mathematics library for Python","archived":false,"fork":false,"pushed_at":"2024-06-15T15:58:07.000Z","size":160,"stargazers_count":5,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T10:09:53.380Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pypi.python.org/pypi/anglr/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Uberi.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-03-23T04:22:23.000Z","updated_at":"2024-10-27T06:22:06.000Z","dependencies_parsed_at":"2024-10-27T18:20:37.370Z","dependency_job_id":"220dedb0-f5e2-47b2-8a90-030eb8b63418","html_url":"https://github.com/Uberi/anglr","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"63d3434556a2f4539cf16fdc9b75bf5275c4fa83"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Uberi%2Fanglr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Uberi%2Fanglr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Uberi%2Fanglr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Uberi%2Fanglr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Uberi","download_url":"https://codeload.github.com/Uberi/anglr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243933431,"owners_count":20370986,"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-10-09T22:27:52.727Z","updated_at":"2026-03-17T17:37:24.976Z","avatar_url":"https://github.com/Uberi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"anglr\r\n=====\r\n\r\n.. image:: https://img.shields.io/pypi/dm/anglr.svg\r\n    :target: https://pypi.python.org/pypi/anglr/\r\n    :alt: Downloads\r\n\r\n.. image:: https://img.shields.io/pypi/v/anglr.svg\r\n    :target: https://pypi.python.org/pypi/anglr/\r\n    :alt: Latest Version\r\n\r\n.. image:: https://img.shields.io/pypi/status/anglr.svg\r\n    :target: https://pypi.python.org/pypi/anglr/\r\n    :alt: Development Status\r\n\r\n.. image:: https://img.shields.io/pypi/pyversions/anglr.svg\r\n    :target: https://pypi.python.org/pypi/anglr/\r\n    :alt: Supported Python Versions\r\n\r\n.. image:: https://img.shields.io/pypi/l/anglr.svg\r\n    :target: https://pypi.python.org/pypi/anglr/\r\n    :alt: License\r\n\r\nPlanar angle mathematics library for Python.\r\n\r\nThis library contains many different functions for converting between units, comparing angles, and doing angle arithmetic.\r\n\r\nLinks:\r\n\r\n-  `PyPI \u003chttps://pypi.python.org/pypi/anglr/\u003e`__\r\n-  `GitHub \u003chttps://github.com/Uberi/anglr\u003e`__\r\n\r\nQuickstart: ``pip3 install anglr``.\r\n\r\nRationale\r\n---------\r\n\r\nConsider the following trivial angle comparison code:\r\n\r\n.. code:: python\r\n\r\n    import math\r\n    heading = get_compass_value() # angle in radians normalized to $[0, 2*pi)$\r\n    if target - math.pi / 4 \u003c= heading \u003c= target + math.pi / 4:\r\n        print(\"Facing the target\")\r\n    else:\r\n        print(\"Not facing the target\")\r\n\r\nAngle code is everywhere. The above is totally, utterly **wrong** (consider what happens when ``target`` is 0), yet this could easily be overlooked while writing and during code review.\r\n\r\nWith anglr, there is a better way:\r\n\r\n.. code:: python\r\n\r\n    import math\r\n    from anglr import Angle\r\n    heading = Angle(get_compass_value())\r\n    if heading.angle_between(target) \u003c= math.pi / 4:\r\n        print(\"Facing the target\")\r\n    else:\r\n        print(\"Not facing the target\")\r\n\r\nMuch better - this will now correctly take modular arithmetic into account when comparing angles.\r\n\r\nExamples\r\n--------\r\n\r\nAngle creation:\r\n\r\n.. code:: python\r\n\r\n    from math import pi\r\n    from anglr import Angle\r\n    print(Angle())\r\n    print(Angle(87 * pi / 2))\r\n    print(Angle(pi / 2, \"radians\"))\r\n    print(Angle(Angle(pi / 2, \"radians\"))) # same as above\r\n    print(Angle(64.2, \"degrees\"))\r\n    print(Angle(384.9, \"gradians\"))\r\n    print(Angle(4.5, \"hours\"))\r\n    print(Angle(203.8, \"arcminutes\"))\r\n    print(Angle(42352.7, \"arcseconds\"))\r\n    print(Angle((56, 32), \"vector\")) # angle in standard position - counterclockwise from positive X-axis\r\n\r\nAngle conversion:\r\n\r\n.. code:: python\r\n\r\n    from anglr import Angle\r\n    x = Angle(58.3)\r\n    print([x], str(x), x.radians, x.degrees, x.gradians, x.hours, x.arcminutes, x.arcseconds, x.vector, x.x, x.y)\r\n    print(complex(x))\r\n    print(float(x))\r\n    print(int(x))\r\n    x.radians = pi / 2\r\n    print(x.dump())\r\n    x.degrees = 64.2\r\n    print(x.dump())\r\n    x.gradians = 384.9\r\n    print(x.dump())\r\n    x.hours = 4.5\r\n    print(x.dump())\r\n    x.arcminutes = 203.8\r\n    print(x.dump())\r\n    x.arcseconds = 42352.7\r\n    print(x.dump())\r\n    x.vector = (56, 32)\r\n    print(x.dump())\r\n\r\nAngle arithmetic:\r\n\r\n.. code:: python\r\n\r\n    from math import pi\r\n    from anglr import Angle\r\n    print(Angle(pi / 6) + Angle(2 * pi / 3))\r\n    print(x * 2 + Angle(3 * pi / 4) / 4 + 5 * Angle(pi / 3))\r\n    print(-abs(+Angle(pi)))\r\n    print(round(Angle(-75.87)))\r\n    print(Angle(-4.3) \u003c= Angle(pi / 4) \u003e Angle(0.118) == Angle(0.118))\r\n    print(Angle(-870.3, \"gradians\").normalized())\r\n    print(Angle(-870.3, \"gradians\").normalized(0)) # same as above\r\n    print(Angle(-870.3, \"gradians\").normalized(0, 2 * pi)) # same as above\r\n    print(Angle(-870.3, \"gradians\").normalized(-pi, pi))\r\n    print(Angle(-870.3, \"gradians\").normalized(-pi, 0))\r\n    print(Angle(1, \"degrees\").angle_between_clockwise(Angle(0, \"degrees\")))\r\n    print(Angle(1, \"degrees\").angle_between(Angle(0, \"degrees\")))\r\n    print(Angle(0, \"degrees\").angle_within(Angle(-45, \"degrees\"), Angle(45, \"degrees\")))\r\n    print(Angle(-1, \"degrees\").angle_within(Angle(-1, \"degrees\"), Angle(1, \"degrees\"), strictly_within=True))\r\n    print(Angle(-1, \"degrees\").angle_to(Angle(180, \"degrees\")))\r\n    print(Angle(0, \"degrees\").angle_to(Angle(180, \"degrees\")))\r\n\r\nTo run all of the above as tests, simply run ``python3 tests.py`` in the project directory.\r\n\r\nInstalling\r\n----------\r\n\r\nThe easiest way to install this is using ``pip3 install anglr``.\r\n\r\nOtherwise, download the source distribution from `PyPI \u003chttps://pypi.python.org/pypi/anglr/\u003e`__, and extract the archive.\r\n\r\nIn the folder, run ``python3 setup.py install``.\r\n\r\nRequirements\r\n------------\r\n\r\nThis library requires Python 3.2 or higher to run.\r\n\r\nAuthors\r\n-------\r\n\r\n::\r\n\r\n    Uberi \u003cazhang9@gmail.com\u003e (Anthony Zhang)\r\n\r\nPlease report bugs and suggestions at the `issue tracker \u003chttps://github.com/Uberi/anglr/issues\u003e`__!\r\n\r\nLicense\r\n-------\r\n\r\nCopyright 2014-2015 `Anthony Zhang (Uberi) \u003chttps://uberi.github.io\u003e`__.\r\n\r\nThe source code is available online at `GitHub \u003chttps://github.com/Uberi/anglr\u003e`__.\r\n\r\nThis program is made available under the 3-clause BSD license. See ``LICENSE.txt`` for more information.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuberi%2Fanglr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuberi%2Fanglr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuberi%2Fanglr/lists"}