{"id":18048461,"url":"https://github.com/ch8n/vektor2d","last_synced_at":"2025-07-17T16:41:04.414Z","repository":{"id":140848554,"uuid":"381633478","full_name":"ch8n/Vektor2D","owner":"ch8n","description":"Vector 2D implementation in Kotlin for Jetpack Compose Canvas API, inspired from p5.js ","archived":false,"fork":false,"pushed_at":"2021-07-14T14:38:33.000Z","size":28,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-10T13:14:32.870Z","etag":null,"topics":["canvas2d","kotlin","library","p5js","vector","vector-math"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/ch8n.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-30T08:43:56.000Z","updated_at":"2023-02-12T13:49:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"e7558179-6ed2-4bc2-81d9-35e26e2495ad","html_url":"https://github.com/ch8n/Vektor2D","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ch8n%2FVektor2D","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ch8n%2FVektor2D/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ch8n%2FVektor2D/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ch8n%2FVektor2D/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ch8n","download_url":"https://codeload.github.com/ch8n/Vektor2D/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289435,"owners_count":20914464,"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":["canvas2d","kotlin","library","p5js","vector","vector-math"],"created_at":"2024-10-30T20:13:00.702Z","updated_at":"2025-04-05T05:16:55.820Z","avatar_url":"https://github.com/ch8n.png","language":"Kotlin","readme":"# Vektor2D\n`2D Vector` implemented in Kotlin for Jetpack Compose Canvas API :rocket:\n\n# Motivation\nRecently I have been poking around with `Jetpack Compose Canvas API` to make some computer graphics stuff which requires lots of Vector maths and operation, some of the cool examples I found were built over one of the processing framework called `p5.js`,  There you will see `p5.Vector`  which represent groupings of coordinate values and make it easy to understand and work with them.\n\n[Official p5.js Reference Guide on Vectors](https://p5js.org/reference/#/p5.Vector) and [Github Source-Code](https://github.com/processing/p5.js/blob/main/src/math/p5.Vector.js) are linked here if you want to refer the original material.\n\nI Have ported over these 2D Vector function over Kotlin, Hope you all enjoy them and for `contribution`/`issues` and discussion follow the [Contribution Guide](https://chetangupta.net) [TODO CONTRIBUTION GUIDE]\n\n## Documentation\nTODO(In progress...)\nYou can recommend me tooling by opening discussion or issues.\n\n## Collection : \n\nVector(`[x]`, `[y]`, `[z]`)\n\n## Parameters\n- `x` Float: x component of the vector (Optional)\n- `y` Float: y component of the vector (Optional)\n- `z` Float: z component of the vector (Optional)\n\n## Methods\n\n| Method      | Description |\n| ----------- | ----------- |\n| toString()      | Returns a string representation of a vector |\n| clone()   | Gets a copy of the vector        |\n| +   | Adds x, y, and z components to a vector, adds one vector to another, or adds two independent vectors together.  |\n| %   |  Gives remainder of a vector when it is divided by another vector. |\n| -   |  Multiplies the vector by a scalar, multiplies the x, y, and z components from a vector, or multiplies the x, y, and z components of two independent vectors |\n| /   |  Divides the vector by a scalar, divides a vector by the x, y, and z arguments, or divides the x, y, and z components of two vectors against each other. |\n| magnitude   | Calculates the magnitude (length) of the vector and returns the result as a float |\n| magnitudeSquare   |  Calculates the squared magnitude of the vector and returns the result as a float        |\n| dot()   |  Calculates the dot product of two vectors.        |\n| cross()   | Calculates and returns a vector composed of the cross product between two vectors        |\n| distance()   | Calculates the Euclidean distance between two points (considering a point as a vector object).        |\n| normalize()   |  Normalize the vector to length 1 (make it a unit vector).        |\n| limit()   |  Limit the magnitude of this vector to the value used for the max parameter.        |\n| setMagnitude()   |  Set the magnitude of this vector to the value used for the len parameter.        |\n| heading()   |  Calculate the angle of rotation for this vector(only 2D vectors)        |\n| setHeading()   | Rotate the vector to a specific angle (only 2D vectors), magnitude remains the same |\n| rotate()   |  Rotate the vector by an angle (only 2D vectors), magnitude remains the same        |\n| angleBetween()   | Calculates and returns the angle between two vectors.        |\n| linearInterpolateTo()   | Linear interpolate the vector to another vector        |\n| reflection()   |  Reflect the incoming vector about a normal to a line in 2D        |\n| toList()   |  Return a representation of this vector as a float array        |\n| equalCoordinates()  | Equality check coordinate values        |\n| vectorOfAngle()  | Make a new 2D vector from an angle|\n| vectorRandom2D()  | Creates a 2D `Unit` Vector with given or random coordinates |\n| vector()  | Creates a 2D Vector with given coordinates |\n\n\n## :eyes: Social\n[LinkedIn](https://bit.ly/ch8n-linkdIn) |\n[Medium](https://bit.ly/ch8n-medium-blog) |\n[Twitter](https://bit.ly/ch8n-twitter) |\n[StackOverflow](https://bit.ly/ch8n-stackOflow) |\n[CodeWars](https://bit.ly/ch8n-codewar) |\n[Portfolio](https://bit.ly/ch8n-home) |\n[Github](https://bit.ly/ch8n-git) |\n[Instagram](https://bit.ly/ch8n-insta) |\n[Youtube](https://bit.ly/ch8n-youtube)\n\n\n## :cop: License\nShield: [![CC BY-SA 4.0][cc-by-sa-shield]][cc-by-sa]\n\nThis work is licensed under a\n[Creative Commons Attribution-ShareAlike 4.0 International License][cc-by-sa].\n\n[![CC BY-SA 4.0][cc-by-sa-image]][cc-by-sa]\n\n[cc-by-sa]: http://creativecommons.org/licenses/by-sa/4.0/\n[cc-by-sa-image]: https://licensebuttons.net/l/by-sa/4.0/88x31.png\n[cc-by-sa-shield]: https://img.shields.io/badge/License-CC%20BY--SA%204.0-lightgrey.svg","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fch8n%2Fvektor2d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fch8n%2Fvektor2d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fch8n%2Fvektor2d/lists"}