Larb

Linear algebra · 2D and 3D

Vectors that speak Ruby.

Ruby math types for graphics: vectors, matrices, quaternions, and colors.

gem install larb

Vec3 · directiondot · cross · normalize

The math behind a transform.

Build from vectors, compose matrices, and represent rotation with quaternions.

01

Move through space

Vec2, Vec3, and Vec4 types with direction helpers.

02

Compose transforms

Matrix and affine-transform types for graphics.

03

Represent rotation

Quaternions, dual quaternions, and color helpers.

A small first step

Start with one example.

Install the gem, then follow the project guide for platform requirements and the full API.

Read the installation guide ↗

require "larb"

position = Larb::Vec3.new(1, 2, 3)
direction = Larb::Vec3.up
rotation = Larb::Quat.from_axis_angle(direction, Math::PI / 4)
rotated = rotation * position

transform = Larb::Mat4.translation(10, 20, 30)