Project

larb

0.0
No release in over 3 years
Larb provides vectors, matrices, quaternions, and Color classes for 2D/3D graphics and mathematical computations
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

 Project Readme

Larb Gem Version CI

Linear algebra library for 2D/3D graphics in Ruby.

Installation

Add this line to your application's Gemfile:

gem 'larb'

And then execute:

bundle install

Or install it yourself as:

gem install larb

Usage

require 'larb'

# Vectors
v2 = Larb::Vec2.new(1, 2)
v3 = Larb::Vec3.new(1, 2, 3)
v4 = Larb::Vec4.new(1, 2, 3, 1)

# Vector operations
sum = v3 + Larb::Vec3.new(4, 5, 6)
dot = v3.dot(Larb::Vec3.new(1, 0, 0))
cross = v3.cross(Larb::Vec3.up)
normalized = v3.normalize

# Matrices
identity = Larb::Mat4.identity
translation = Larb::Mat4.translation(10, 20, 30)
rotation = Larb::Mat4.rotation_y(Math::PI / 4)
scale = Larb::Mat4.scaling(2, 2, 2)

# Matrix multiplication
transform = translation * rotation * scale
transformed_point = transform * v4

# Quaternions
quat = Larb::Quat.from_axis_angle(Larb::Vec3.up, Math::PI / 2)
rotated = quat * Larb::Vec3.new(1, 0, 0)

# Colors
red = Larb::Color.red
custom = Larb::Color.new(0.5, 0.3, 0.8, 1.0)
hex_color = Larb::Color.from_hex("#ff8800")

Development

# Install dependencies
bundle install

# Compile native extension
bundle exec rake compile

# Run tests
bundle exec rake test

License

The gem is available as open source under the terms of the MIT License.