sixarm_ruby_geometry

SixArm.com » Ruby » Geometry modules for points, spaces, arrays, vectors, etc.

https://github.com/sixarm/sixarm_ruby_geometry

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.7%) to scientific vocabulary

Keywords

gem geometry ruby
Last synced: 4 months ago · JSON representation ·

Repository

SixArm.com » Ruby » Geometry modules for points, spaces, arrays, vectors, etc.

Basic Info
  • Host: GitHub
  • Owner: SixArm
  • License: other
  • Language: Ruby
  • Default Branch: main
  • Homepage: http://sixarm.com
  • Size: 425 KB
Statistics
  • Stars: 0
  • Watchers: 4
  • Forks: 1
  • Open Issues: 1
  • Releases: 0
Topics
gem geometry ruby
Created over 10 years ago · Last pushed 9 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation Codeowners

README.md

SixArm.com → Ruby →
Geometry modules

Gem Version Build Status Code Climate

Introduction

Geometry modules for points, spaces, arrays, vectors, math, etc.

These modules are minimal building blocks for larger apps, providing namespaces and broadly useful implemenation methods.

Example of a point:

class Point < Array
  include Indexable::XY  # Accessors for x and y
end

point = Point[10, 20]
point.x #=> 10
point.y #=> 20

Example of a space:

class Space < Array
  include Indexable::WidthHeight  # Accessors for width and height
end

space = Space[10, 20]
space.width  #=> 10
space.height #=> 20

Example of geometry math:

class Airplane < Array
  include Indexable::Pitch  # Mix in method
  include Indexable::Yaw    # Mix in method
end

airplane = Airplane[3, 4, 5]
airplane.pitch #=> 0.7853981633974483
airplane.yaw #=> -0.9272952180016122

The complete docs are at http://sixarm.com/sixarm_ruby_geometry/doc

Want to help? We're happy to get pull requests.

Install

Gem

To install this gem in your shell or terminal:

gem install sixarm_ruby_geometry

Gemfile

To add this gem to your Gemfile:

gem 'sixarm_ruby_geometry'

Require

To require the gem in your code:

require 'sixarm_ruby_geometry'

Usage

Point

A point class is easy to implement as an array or vector.

Example of a point implemented as an array:

class Point < Array
end

Example of a point implemented as a vector:

require 'matrix'
class Point < Vector
end

Addition and subtraction:

Space

A space class is easy to implement as an array or vector.

Example of a space implemented as an array:

class Space < Array
end

Example of a space implemented as a vector:

require 'matrix'
class Space < Vector
end

Indexable

Marker modules that provide semantic information:

  • Indexable::D1: Dimension 1, responds to [0].
  • Indexable::D2: Dimension 2, responds to [0], [1].
  • Indexable::D3: Dimension 3, responds to [0], [1], [2].

Mix in methods for x, y, z:

  • Indexable::X: mix in methods x, x=, accessing [0].
  • Indexable::XY: mix in methods x, x=, y, y=, accessing [0], [1].
  • Indexable::XYZ: mix in methods x, x=, y, y=, z, z=, accessing [0], [1], [2].

Mix in methods for width, height, depth:

  • Indexable::Width: mix in methods width, width=, accessing [0].
  • Indexable::WidthHeight: mix in methods width, width=, height, height=, accessing [0], [1].
  • Indexable::WidthHeightDepth: mix in methods width, width=, height, height=, depth, depth=, accessing [0], [1], [2].

Mix in methods for geometry math:

  • Indexable::Rad: calculate a 2-dimensional angle in radians, accessing [0], [1].
  • Indexable::Pitch: calculate a 3-dimensional pitch, i.e. angle from xy plane to z, accessing [0], [1], [2].
  • Indexable::Yaw: calculate a 3-dimensional yaw, i.e. angle within xy plane, accessing [0], [1], [2].

Marker Modules

If you're creating a class, then you may like to emphasize the intent of the class by using marker modules.

These modules are all blank by default; you may add your own code to them as you like.

Point modules:

  • Point
  • Point::Array
  • Point::Array::D1
  • Point::Array::D2
  • Point::Array::D3
  • Point::Vector
  • Point::Vector::D1
  • Point::Vector::D2
  • Point::Vector::D3

Space modules:

  • Space
  • Space::Array
  • Space::Array::D1
  • Space::Array::D2
  • Space::Array::D3
  • Space::Vector
  • Space::Vector::D1
  • Space::Vector::D2
  • Space::Vector::D3

Examples of geometry shapes, implemented with arrays:

class Line
  include Space::Array::D1
end

class Square
  include Space::Array::D2
end

class Cube
  include Space::Array::D3
end

Examples of a chess board and chess piece, implemented with vectors:

class ChessBoard
  include Space::Vector::2D
end

class ChessPiece
  include Point::Vector::2D
end

Array Element Math

A point array has methods for + and -:

# Define a point class
class C < Array
   include Point::Array
end

# Define some points
a = C[1, 1]
b = C[2, 2]

# Add
a + b #=> [3, 3]

# Subtract
a - b #=> [-1, -1]

Owner

  • Name: SixArm
  • Login: SixArm
  • Kind: organization
  • Email: sixarm@sixarm.com
  • Location: San Francisco

SixArm Software

Citation (CITATION.cff)

cff-version: 1.2.0
title: SixArm.com → Ruby → <br> Geometry modules
message: >-
  If you use this work and you want to cite it,
  then you can use the metadata from this file.
type: software
authors:
  - given-names: Joel Parker
    family-names: Henderson
    email: joel@joelparkerhenderson.com
    affiliation: joelparkerhenderson.com
    orcid: 'https://orcid.org/0009-0000-4681-282X'
identifiers:
  - type: url
    value: 'https://github.com/SixArm/sixarm_ruby_geometry/'
    description: SixArm.com → Ruby → <br> Geometry modules
repository-code: 'https://github.com/SixArm/sixarm_ruby_geometry/'
abstract: >-
  SixArm.com → Ruby → <br> Geometry modules
license: See license file

GitHub Events

Total
  • Push event: 1
Last Year
  • Push event: 1

Committers

Last synced: 11 months ago

All Time
  • Total Commits: 95
  • Total Committers: 3
  • Avg Commits per committer: 31.667
  • Development Distribution Score (DDS): 0.084
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Joel Parker Henderson j****l@j****m 87
William Stuart Lazar b****r@g****m 7
Michael Pope m****r@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 9 months ago

All Time
  • Total issues: 1
  • Total pull requests: 11
  • Average time to close issues: N/A
  • Average time to close pull requests: 4 minutes
  • Total issue authors: 1
  • Total pull request authors: 2
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.09
  • Merged pull requests: 11
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • billsaysthis (1)
Pull Request Authors
  • billsaysthis (7)
  • amorphid (1)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

sixarm_ruby_geometry.gemspec rubygems
  • flay >= 2.12.0, < 3 development
  • flog >= 4.6.2, < 5 development
  • minitest >= 5.11.3, < 6 development
  • rake >= 12.3.1, < 13 development
  • reek >= 4.8.1, < 5 development
  • rubocop >= 0.57.2, < 1 development
  • rubycritic >= 3.4.0, < 4 development
  • simplecov >= 0.16.1, < 2 development
  • sixarm_ruby_minitest_extensions >= 1.0.8, < 2 development
.github/workflows/ruby.yml actions
  • actions/checkout v3 composite
  • ruby/setup-ruby v1 composite
Gemfile rubygems
Gemfile.lock rubygems
  • addressable 2.8.4
  • ast 2.4.2
  • axiom-types 0.1.1
  • bundler 2.3.26
  • codeclimate-engine-rb 0.4.2
  • coercible 1.0.0
  • descendants_tracker 0.0.4
  • docile 1.4.0
  • equalizer 0.0.11
  • erubi 1.12.0
  • flay 2.13.0
  • flog 4.6.6
  • ice_nine 0.11.2
  • jaro_winkler 1.5.5
  • launchy 2.4.3
  • minitest 5.18.0
  • parallel 1.23.0
  • parser 2.5.3.0
  • path_expander 1.1.1
  • public_suffix 5.0.1
  • rainbow 3.1.1
  • rake 12.3.3
  • reek 4.8.2
  • rubocop 0.68.1
  • ruby-progressbar 1.13.0
  • ruby_parser 3.20.1
  • rubycritic 3.5.2
  • sexp_processor 4.17.0
  • simplecov 0.22.0
  • simplecov-html 0.12.3
  • simplecov_json_formatter 0.1.4
  • sixarm_ruby_geometry 4.0.0
  • sixarm_ruby_minitest_extensions 1.1.1
  • thread_safe 0.3.6
  • tty-which 0.3.0
  • unicode-display_width 1.5.0
  • virtus 1.0.5