{"id":20511041,"url":"https://github.com/sean-codes/vector-concepts","last_synced_at":"2025-04-13T22:41:29.514Z","repository":{"id":91334798,"uuid":"110490688","full_name":"sean-codes/vector-concepts","owner":"sean-codes","description":"Storing some vector math experiments","archived":false,"fork":false,"pushed_at":"2020-06-15T03:29:40.000Z","size":3654,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T13:01:44.048Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://sean-codes.github.io/vector-concepts/#/experiments/circleCollision.js","language":"JavaScript","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/sean-codes.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}},"created_at":"2017-11-13T02:32:32.000Z","updated_at":"2023-12-30T10:00:40.000Z","dependencies_parsed_at":"2023-06-04T12:45:14.061Z","dependency_job_id":null,"html_url":"https://github.com/sean-codes/vector-concepts","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/sean-codes%2Fvector-concepts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sean-codes%2Fvector-concepts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sean-codes%2Fvector-concepts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sean-codes%2Fvector-concepts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sean-codes","download_url":"https://codeload.github.com/sean-codes/vector-concepts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248794423,"owners_count":21162613,"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-15T20:34:18.372Z","updated_at":"2025-04-13T22:41:29.482Z","avatar_url":"https://github.com/sean-codes.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vector-concepts\n\u003e A repository I use to adventure, explore, and understand geometry / vector mathematics.\n\n![Example GIF](https://raw.githubusercontent.com/sean-codes/vector-concepts/master/example.gif?v=2)\n\nView Experiments: [click here](https://sean-codes.github.io/vector-concepts/)\n\n## 🗺 Explored\n- Scene setup / Loop\n- Unit Circle\n- SIN/COS/TAN\n- Basic Vector Math ( Adding, Subtracting, Scale, Distance )\n- Rotation\n- Dot Product\n- Projection with Dot Product\n- Axis Aligned Bounding Box Collision (AABB)\n- Separate Axis Collisions (SAT)\n\n## 📙 Journal\n\n#### Radians\nHalf of a circle = 180deg or `Math.PI` radians. A entire circle is 360deg or `Math.PI*2` radians. That is 6.28 radians in a circle. In a unit circle the circumference if equal to Math.PI*2\n\nRadian to Degree\n\n```js\n   var deg = rad * 180/Math.PI\n```\n\nDegree to Radian\n```js\n   var rad = deg * Math.PI/180\n```\n\n### Sin, Cos, Tan are ratios\nWhen thinking about sin, cos, tan it can be intuitive to think of the unit circle and solve a triangle using the ratios\n\n```\nsin: From -1 to 1 the Y\ncos: From -1 to 1 the X\ntan: can go above 1. the heigth of the wall\n```\n\n#### Cartesian vs Polar\n**Cartesian**: using x/y to define a position\n\n**Polar**: Using angle and length to define a position\n\n##### Polar to Cartesian conversion. angle and length to (x, y):\n``` js\n var x = length * Math.cos(angle)\n var y = length * Math.sin(angle)\n```\n\n### DOT Product\n\nThe most mystical equation\n```js\nvar dot = vector1.x * vector2.x + vector1.y * vector2.y\n```\n\nThe dot product gives us a relationship of two vectors. It is useful for finding the angle\n\n##### Finding the angle between two vectors using DOT Product\n\nThe angle is equal to the DOT product of the vectors divided by their lengths multiplied\n\n```js\n// cos(Angle) = dot(V1, V2) / (v1.length * v2.length)\nvar dot = vector1.dot(vector2)\nvar cosAngle = dot / (vector1.length() * vector2.length())  // -1 to 1\nvar angle = acos(cosAngle) // 180 - 0\n```\n\n\n## 📚 Library\n- http://blog.wolfire.com/2009/07/linear-algebra-for-game-developers-part-1/\n- http://www.helixsoft.nl/articles/circle/sincos.htm\n- https://www.khanacademy.org/math/trigonometry\n- http://www-groups.dcs.st-and.ac.uk/history/HistTopics/Trigonometric_functions.html\n- https://betterexplained.com/articles/intuitive-trigonometry/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsean-codes%2Fvector-concepts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsean-codes%2Fvector-concepts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsean-codes%2Fvector-concepts/lists"}