{"id":22808297,"url":"https://github.com/sixarm/sixarm_ruby_geometry","last_synced_at":"2025-03-30T21:15:42.605Z","repository":{"id":34698266,"uuid":"38673625","full_name":"SixArm/sixarm_ruby_geometry","owner":"SixArm","description":"SixArm.com » Ruby » Geometry modules for points, spaces, arrays, vectors, etc.","archived":false,"fork":false,"pushed_at":"2023-09-15T19:28:14.000Z","size":435,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-02-06T00:25:14.393Z","etag":null,"topics":["gem","geometry","ruby"],"latest_commit_sha":null,"homepage":"http://sixarm.com","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SixArm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null}},"created_at":"2015-07-07T08:13:40.000Z","updated_at":"2023-05-22T14:11:32.000Z","dependencies_parsed_at":"2022-07-09T02:00:31.171Z","dependency_job_id":null,"html_url":"https://github.com/SixArm/sixarm_ruby_geometry","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/SixArm%2Fsixarm_ruby_geometry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SixArm%2Fsixarm_ruby_geometry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SixArm%2Fsixarm_ruby_geometry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SixArm%2Fsixarm_ruby_geometry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SixArm","download_url":"https://codeload.github.com/SixArm/sixarm_ruby_geometry/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246379366,"owners_count":20767696,"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":["gem","geometry","ruby"],"created_at":"2024-12-12T11:09:00.032Z","updated_at":"2025-03-30T21:15:42.588Z","avatar_url":"https://github.com/SixArm.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SixArm.com → Ruby → \u003cbr\u003e Geometry modules\n\n\u003c!--header-open--\u003e\n\n[![Gem Version](https://badge.fury.io/rb/sixarm_ruby_geometry.svg)](http://badge.fury.io/rb/sixarm_ruby_geometry)\n[![Build Status](https://travis-ci.org/SixArm/sixarm_ruby_geometry.png)](https://travis-ci.org/SixArm/sixarm_ruby_geometry)\n[![Code Climate](https://api.codeclimate.com/v1/badges/9ea67823a1cb274c76d5/maintainability)](https://codeclimate.com/github/SixArm/sixarm_ruby_geometry/maintainability)\n\n* Git: \u003chttps://github.com/SixArm/sixarm_ruby_geometry\u003e\n* Doc: \u003chttp://sixarm.com/sixarm_ruby_geometry/doc\u003e\n* Gem: \u003chttps://rubygems.org/gems/sixarm_ruby_geometry\u003e\n* Contact: Joel Parker Henderson, \u003cjoel@sixarm.com\u003e\n* Project: [changes](CHANGES.md), [license](LICENSE.md), [contributing](CONTRIBUTING.md).\n\n\u003c!--header-shut--\u003e\n\n\n## Introduction\n\nGeometry modules for points, spaces, arrays, vectors, math, etc.\n\nThese modules are minimal building blocks for larger apps, providing namespaces and broadly useful implemenation methods.\n\nExample of a point:\n\n    class Point \u003c Array\n      include Indexable::XY  # Accessors for x and y\n    end\n\n    point = Point[10, 20]\n    point.x #=\u003e 10\n    point.y #=\u003e 20\n\n\nExample of a space:\n\n    class Space \u003c Array\n      include Indexable::WidthHeight  # Accessors for width and height\n    end\n\n    space = Space[10, 20]\n    space.width  #=\u003e 10\n    space.height #=\u003e 20\n\n\nExample of geometry math:\n\n    class Airplane \u003c Array\n      include Indexable::Pitch  # Mix in method\n      include Indexable::Yaw    # Mix in method\n    end\n\n    airplane = Airplane[3, 4, 5]\n    airplane.pitch #=\u003e 0.7853981633974483\n    airplane.yaw #=\u003e -0.9272952180016122\n\nThe complete docs are at \u003chttp://sixarm.com/sixarm_ruby_geometry/doc\u003e\n\nWant to help? We're happy to get pull requests.\n\n\n\u003c!--install-open--\u003e\n\n## Install\n\n### Gem\n\nTo install this gem in your shell or terminal:\n\n    gem install sixarm_ruby_geometry\n\n### Gemfile\n\nTo add this gem to your Gemfile:\n\n    gem 'sixarm_ruby_geometry'\n\n### Require\n\nTo require the gem in your code:\n\n    require 'sixarm_ruby_geometry'\n\n\u003c!--install-shut--\u003e\n\n\n## Usage\n\n\n### Point\n\nA point class is easy to implement as an array or vector.\n\nExample of a point implemented as an array:\n\n    class Point \u003c Array\n    end\n\nExample of a point implemented as a vector:\n\n    require 'matrix'\n    class Point \u003c Vector\n    end\n\nAddition and subtraction:\n\n\n### Space\n\nA space class is easy to implement as an array or vector.\n\nExample of a space implemented as an array:\n\n    class Space \u003c Array\n    end\n\nExample of a space implemented as a vector:\n\n    require 'matrix'\n    class Space \u003c Vector\n    end\n\n\n### Indexable\n\nMarker modules that provide semantic information:\n\n* `Indexable::D1`: Dimension 1, responds to `[0]`.\n* `Indexable::D2`: Dimension 2, responds to `[0]`, `[1]`.\n* `Indexable::D3`: Dimension 3, responds to `[0]`, `[1]`, `[2]`.\n\nMix in methods for x, y, z:\n\n* `Indexable::X`: mix in methods `x`, `x=`, accessing `[0]`.\n* `Indexable::XY`: mix in methods `x`, `x=`, `y`, `y=`, accessing `[0]`, `[1]`.\n* `Indexable::XYZ`: mix in methods `x`, `x=`, `y`, `y=`, `z`, `z=`, accessing `[0]`, `[1]`, `[2]`.\n\nMix in methods for width, height, depth:\n\n* `Indexable::Width`: mix in methods `width`, `width=`, accessing `[0]`.\n* `Indexable::WidthHeight`: mix in methods `width`, `width=`, `height`, `height=`, accessing `[0]`, `[1]`.\n* `Indexable::WidthHeightDepth`: mix in methods `width`, `width=`, `height`, `height=`, `depth`, `depth=`, accessing `[0]`, `[1]`, `[2]`.\n\nMix in methods for geometry math:\n\n* `Indexable::Rad`: calculate a 2-dimensional angle in radians, accessing `[0]`, `[1]`.\n* `Indexable::Pitch`: calculate a 3-dimensional pitch, i.e. angle from xy plane to z, accessing `[0]`, `[1]`, `[2]`.\n* `Indexable::Yaw`: calculate a 3-dimensional yaw, i.e. angle within xy plane, accessing `[0]`, `[1]`, `[2]`.\n\n\n### Marker Modules\n\nIf you're creating a class, then you may like to emphasize the intent of the class by using marker modules.\n\nThese modules are all blank by default; you may add your own code to them as you like.\n\nPoint modules:\n\n* `Point`\n* `Point::Array`\n* `Point::Array::D1`\n* `Point::Array::D2`\n* `Point::Array::D3`\n* `Point::Vector`\n* `Point::Vector::D1`\n* `Point::Vector::D2`\n* `Point::Vector::D3`\n\nSpace modules:\n\n* `Space`\n* `Space::Array`\n* `Space::Array::D1`\n* `Space::Array::D2`\n* `Space::Array::D3`\n* `Space::Vector`\n* `Space::Vector::D1`\n* `Space::Vector::D2`\n* `Space::Vector::D3`\n\nExamples of geometry shapes, implemented with arrays:\n\n    class Line\n      include Space::Array::D1\n    end\n\n    class Square\n      include Space::Array::D2\n    end\n\n    class Cube\n      include Space::Array::D3\n    end\n\nExamples of a chess board and chess piece, implemented with vectors:\n\n    class ChessBoard\n      include Space::Vector::2D\n    end\n\n    class ChessPiece\n      include Point::Vector::2D\n    end\n\n\n### Array Element Math\n\nA point array has methods for `+` and `-`:\n\n    # Define a point class\n    class C \u003c Array\n       include Point::Array\n    end\n\n    # Define some points\n    a = C[1, 1]\n    b = C[2, 2]\n\n    # Add\n    a + b #=\u003e [3, 3]\n\n    # Subtract\n    a - b #=\u003e [-1, -1]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsixarm%2Fsixarm_ruby_geometry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsixarm%2Fsixarm_ruby_geometry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsixarm%2Fsixarm_ruby_geometry/lists"}