{"id":15043622,"url":"https://github.com/lace/vg","last_synced_at":"2025-04-06T16:14:13.777Z","repository":{"id":33096005,"uuid":"151337169","full_name":"lace/vg","owner":"lace","description":"Vector-geometry toolbelt for 3D points and vectors","archived":false,"fork":false,"pushed_at":"2023-03-01T13:57:31.000Z","size":345,"stargazers_count":121,"open_issues_count":8,"forks_count":16,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-30T15:07:55.986Z","etag":null,"topics":["3d-points","3d-vectors","geometry","linear-algebra","numpy","shortcuts","toolbelt","vector","vectors"],"latest_commit_sha":null,"homepage":"https://vgpy.dev/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lace.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2018-10-02T23:30:56.000Z","updated_at":"2025-03-21T17:13:43.000Z","dependencies_parsed_at":"2024-06-18T18:41:58.142Z","dependency_job_id":null,"html_url":"https://github.com/lace/vg","commit_stats":{"total_commits":148,"total_committers":10,"mean_commits":14.8,"dds":"0.28378378378378377","last_synced_commit":"44d3fd6b9e7dff0107d117d0a1beac2ec9c7ea2f"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lace%2Fvg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lace%2Fvg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lace%2Fvg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lace%2Fvg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lace","download_url":"https://codeload.github.com/lace/vg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247509237,"owners_count":20950232,"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":["3d-points","3d-vectors","geometry","linear-algebra","numpy","shortcuts","toolbelt","vector","vectors"],"created_at":"2024-09-24T20:49:21.061Z","updated_at":"2025-04-06T16:14:13.758Z","avatar_url":"https://github.com/lace.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"vg\n==\n\n[![version](https://img.shields.io/pypi/v/vg.svg?style=flat-square)][pypi]\n[![python version](https://img.shields.io/pypi/pyversions/vg.svg?style=flat-square)][pypi]\n[![license](https://img.shields.io/pypi/l/vg.svg?style=flat-square)][pypi]\n[![](https://img.shields.io/badge/coverage-100%25-brightgreen.svg?style=flat-square)][coverage]\n[![build](https://img.shields.io/circleci/project/github/lace/vg/master.svg?style=flat-square)][build]\n[![code style](https://img.shields.io/badge/code%20style-black-black.svg?style=flat-square)][black]\n\nA **v**ery **g**ood vector-geometry toolbelt for dealing with 3D points and\nvectors. These are simple [NumPy][] operations made readable, built to scale\nfrom prototyping to production.\n\n:book: See the complete documentation: https://vgpy.dev/\n\n[pypi]: https://pypi.org/project/vg/\n[coverage]: https://github.com/lace/vg/blob/master/.coveragerc\n[build]: https://circleci.com/gh/lace/vg/tree/master\n[black]: https://black.readthedocs.io/en/stable/\n[lace]: https://github.com/metabolize/lace\n[numpy]: https://www.numpy.org/\n\nExamples\n--------\n\nNormalize a stack of vectors:\n\n```py\n# 😮\nvs_norm = vs / np.linalg.norm(vs, axis=1)[:, np.newaxis]\n\n# 😀\nvs_norm = vg.normalize(vs)\n```\n\nCheck for the zero vector:\n\n```py\n# 😣\nis_almost_zero = np.allclose(v, np.array([0.0, 0.0, 0.0]), rtol=0, atol=1e-05)\n\n# 🤓\nis_almost_zero = vg.almost_zero(v, atol=1e-05)\n```\n\nFind the major axis of variation (first principal component):\n\n```py\n# 😩\nmean = np.mean(coords, axis=0)\n_, _, pcs = np.linalg.svd(coords - mean)\nfirst_pc = pcs[0]\n\n# 😍\nfirst_pc = vg.major_axis(coords)\n```\n\nCompute pairwise angles between two stacks of vectors:\n\n```py\n# 😭\ndot_products = np.einsum(\"ij,ij-\u003ei\", v1s.reshape(-1, 3), v2s.reshape(-1, 3))\ncosines = dot_products / np.linalg.norm(v1s, axis=1) / np.linalg.norm(v2s, axis=1)\nangles = np.arccos(np.clip(cosines, -1.0, 1.0))\n\n# 🤯\nangles = vg.angle(v1s, v2s)\n```\n\nInstallation\n------------\n\n```sh\npip install numpy vg\n```\n\n\nUsage\n-----\n\n```py\nimport numpy as np\nimport vg\n\nprojected = vg.scalar_projection(\n  np.array([5.0, -3.0, 1.0]),\n  onto=vg.basis.neg_y\n)\n```\n\n\nDevelopment\n-----------\n\nFirst, [install Poetry][].\n\nAfter cloning the repo, run `./bootstrap.zsh` to initialize a virtual\nenvironment with the project's dependencies.\n\nSubsequently, run `./dev.py install` to update the dependencies.\n\n[install poetry]: https://python-poetry.org/docs/#installation\n\n\nAcknowledgements\n----------------\n\nThis collection was developed at Body Labs by [Paul Melnikow][] and extracted\nfrom the Body Labs codebase and open-sourced as part of [blmath][] by [Alex\nWeiss][]. blmath was subsequently [forked][fork] by Paul Melnikow and later\nthe `vx` namespace was broken out into its own package. The project was renamed\nto `vg` to resolve a name conflict.\n\n[paul melnikow]: https://github.com/paulmelnikow\n[blmath]: https://github.com/bodylabs/blmath\n[alex weiss]: https://github.com/algrs\n[fork]: https://github.com/metabolize/blmath\n\n\nLicense\n-------\n\nThe project is licensed under the two-clause BSD license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flace%2Fvg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flace%2Fvg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flace%2Fvg/lists"}