{"id":13711684,"url":"https://github.com/omaraaa/VecFns","last_synced_at":"2025-05-06T21:31:57.113Z","repository":{"id":43725443,"uuid":"440846957","full_name":"omaraaa/VecFns","owner":"omaraaa","description":"Automatic Vector Math Functions In Zig","archived":false,"fork":false,"pushed_at":"2023-08-26T21:11:37.000Z","size":38,"stargazers_count":23,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-03T23:23:41.546Z","etag":null,"topics":["gamedev","library","math","zig"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit-0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/omaraaa.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}},"created_at":"2021-12-22T12:14:36.000Z","updated_at":"2024-05-29T09:14:30.000Z","dependencies_parsed_at":"2024-04-17T11:34:56.541Z","dependency_job_id":"4140c67c-f3f6-4fdb-9b80-b68d5a01233c","html_url":"https://github.com/omaraaa/VecFns","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/omaraaa%2FVecFns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaraaa%2FVecFns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaraaa%2FVecFns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaraaa%2FVecFns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omaraaa","download_url":"https://codeload.github.com/omaraaa/VecFns/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224535392,"owners_count":17327527,"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":["gamedev","library","math","zig"],"created_at":"2024-08-02T23:01:10.620Z","updated_at":"2024-11-13T22:30:30.944Z","avatar_url":"https://github.com/omaraaa.png","language":"Zig","funding_links":[],"categories":["Libraries","Data \u0026 Science"],"sub_categories":["Linear Algebra"],"readme":"# VecFns\nAutomatic vector math functions for your vector structs.\n\n### Usage\n\nJust add `VecFns` with `usingnamespace` to your struct, you will get the usual math functions for your vector. All fields of the struct should be the same type, and also be numeric. \n\n```zig\nconst VecFns = @import(\"./vec_fns.zig\").VecFns;\n\nconst MyVec = struct {\n  pub usingnamespace VecFns(@This());\n  a: i32,\n  b: i32,\n  c: i32\n};\n\n\nconst Vec2f = struct {\n  pub usingnamespace VecFns(@This());\n  x: f64,\n  y: f64,\n};\n\n```\n\n### Functions\n\nThe following functions will be in the namespace of your struct type after including `VecFns`.\n\n```zig\n// Applies a function `f` to the vector. `args` is any additional arguments to be passed to `f`.\nfn map(self: Self, comptime f: anytype, args: anytype) Self\n\n// Same as `map` but without args argument.\nfn apply(self: Self, comptime f: anytype) Self\n\n// Applies a function `f` to 2 vectors.\nfn map2(a: anytype, b: anytype, comptime f: anytype, args: anytype) Self\n\n// Same as `map`, reduces the vector into a single value.\nfn reduce(self: Self, comptime f: anytype, args: anytype) T\n\n// Adds either 2 vectors or a vector and a scalar value.\nfn add(self: Self, other: anytype) Self\n\n// Subtracts either 2 vectors or a vector and a scalar value.\nfn sub(self: Self, other: anytype) Self\n\n// Multiplies either 2 vectors or a vector and a scalar value.\nfn mul(self: Self, other: anytype) Self\n\n// Divides either 2 vectors or a vector and a scalar value.\nfn div(self: Self, other: anytype) Self\n\n// Same as div, but uses `@divExact`\nfn divExact(self: Self, other: anytype) Self\n\n// Same as div, but uses `@divFloor`\nfn divFloor(self: Self, other: anytype) Self\n\n// Returns the sum of the vector.\nfn sum(self: Self) T\n\n// Given 2 vectors or a vector and a scalar value, returns a vector with the maximum between the 2.\nfn max(self: Self, other: Self) Self\n\n// Given 2 vectors or a vector and a scalar value, returns a vector with the minimum between the 2.\nfn min(self: Self, other: Self) Self\n\n// Checks if the vector is equal to `other` (can be a vector or a scalar)\nfn eq(self: Self, other: anytype) bool\n\n// Attempts to covert/cast the vector into another vector type. \nfn into(self: Self, comptime VType: type) VType\n\n// Joins two vector into a vector size 2\\*N.\nfn join(self: Self, other: Self) [2 * N]T\n\n// Returns the zero vector.\nfn zero() Self\n\n// Returns a vector where all values are `n`.\nfn all(n: anytype) Self\n\n// Coverts the vector into an array of type `[N]T`.\nfn toArray(self: Self) [N]T\n\n// Create a vector from an array.\nfn fromArray(array: [N]T) Self\n\n// Length of the vector. (Float only)\nfn len(self: Self) T\n\n// Distance between 2 vectors. (Float only)\nfn distance(self: Self, other: anytype) T\n\n// Normalizes the vector values to [0, 1]. (Float only)\nfn norm(self: Self) Self\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomaraaa%2FVecFns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomaraaa%2FVecFns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomaraaa%2FVecFns/lists"}