{"id":49070290,"url":"https://github.com/pgdr/tangent_lines_to_two_unit_circles","last_synced_at":"2026-04-20T07:05:40.459Z","repository":{"id":341825728,"uuid":"1171638934","full_name":"pgdr/tangent_lines_to_two_unit_circles","owner":"pgdr","description":null,"archived":false,"fork":false,"pushed_at":"2026-03-03T14:33:21.000Z","size":53,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-03-03T16:57:41.750Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pgdr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-03T12:58:03.000Z","updated_at":"2026-03-03T14:33:25.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/pgdr/tangent_lines_to_two_unit_circles","commit_stats":null,"previous_names":["pgdr/tangent_lines_to_two_unit_circles"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/pgdr/tangent_lines_to_two_unit_circles","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgdr%2Ftangent_lines_to_two_unit_circles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgdr%2Ftangent_lines_to_two_unit_circles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgdr%2Ftangent_lines_to_two_unit_circles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgdr%2Ftangent_lines_to_two_unit_circles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgdr","download_url":"https://codeload.github.com/pgdr/tangent_lines_to_two_unit_circles/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgdr%2Ftangent_lines_to_two_unit_circles/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32036803,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2026-04-20T07:05:39.183Z","updated_at":"2026-04-20T07:05:40.444Z","avatar_url":"https://github.com/pgdr.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Inner tangent line for two unit circle placed with centers at y = 0 and one in origo\n\nThis script computes the tangent point (and corresponding angle) for the inner tangent line of two\nunit circles: one centered at $(0,0)$ and one centered at $(d,0)$.\n\nOne can find the tangent line by imagining a rectangle placed with\nbottom left at $(0,0)$ (origo) and height 2, with unknown length.\n\n## Tangent line\n\n[![](assets/tangent.gif)](https://github.com/pgdr/tangent_lines_to_two_unit_circles/raw/refs/heads/master/assets/tangent.mp4)\n\n\n![](assets/rect.png)\n\n\nThen rotate the rectangle around origo until the top side hits $(d,0)$.\n\nThis results in a triangle with hypothenus $d$, one leg has side $2$,\nwhich gives (soh-**cah**-toa) $\\cos(\\theta) = 2/d$ and thus\n\n$$\\theta = \\arccos(2/d).$$\n\n![](assets/rect2.png)\n\nThen, given $\\theta$, we can find the tangent point on the first\n(left-most) unit circle as simply the unit vector with given\nangle. Here we piggy-back on the complex class in Python to find the\ncoordinates (real=x, imag=y), using `cmath.rect(r, theta)`.\n\n## Usage\n\n```bash\npython tangent.py \u003cd\u003e\n````\n\nExample:\n\n```bash\n$ python tangent.py 5\n```\n\noutputs\n\n```\ntangent at (0.4, 0.917)\nθ = 66.422°\nΔ = ((0, 0), (0.4, 0.917), (2.5, 0))\n```\n\nThe script prints:\n\n* the tangent point on the left circle,\n* $\\theta$ in degrees,\n* and a small helper triangle `Δ` for inspection.\n\n\n## Code\n\n```python\nimport math, cmath\n\ndef tangent_angle(d):\n    theta = math.acos(2 / d)\n    return theta\n\nd = 5.0\ntheta = tangent_angle(d)\nc = cmath.rect(1, theta)\n\nprint(f\"tangent at {(c.real),(c.imag)}\")\nprint(f\"θ = {math.degrees(theta)}°\")\nprint(f\"Δ = ((0,0), {(c.real),(c.imag)}, {(d/2), 0})\")\n```\n\n\n## Animation\n\n![](assets/circles.gif)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgdr%2Ftangent_lines_to_two_unit_circles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgdr%2Ftangent_lines_to_two_unit_circles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgdr%2Ftangent_lines_to_two_unit_circles/lists"}