Skip to content

A lightweight and ergonomic Rust crate for defining, composing, and applying 2D affine transformations.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

Neil-Crago/tma_engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crates.io Docs.rs License: MIT OR Apache-2.0 Rust

TMA Engine: Affine Transformation Toolkit

A lightweight and ergonomic Rust crate for defining, composing, and applying 2D affine transformations.

TMA stands for Transformation, Matrix, Affine. This engine provides the core algebraic structures for working with Iterated Function Systems (IFS), which are the mathematical foundation for generating a wide variety of fractals, including the Sierpinski Gasket and Barnsley's Fern.

Features

  • Clear Algebraic Structure: The TMA struct cleanly represents the transformation T(v) = A*v + c.
  • Operator Overloading: Use the * operator to naturally compose transformations (TMA * TMA) or apply them to points (TMA * Point).
  • Stochastic IFS Support: Includes an optional probability field in the TMA struct, essential for algorithms like the Chaos Game.
  • Helper Constructors: Provides convenient methods for creating common transformations like scaling, rotation, and translation.

Usage

Add this crate to your Cargo.toml:

[dependencies]
tma_engine = "0.1.8" # Or the latest version

Example

use tma_engine::{TMA, Point};

fn main() {
    let scale_half = TMA::from_scale(0.5);
    let rotate_90_deg = TMA::from_rotation(std::f64::consts::FRAC_PI_2);
    let translate_up = TMA::from_translation(0.0, 1.0);

    // Compose transformations using the multiplication operator.
    // The right-most operation is applied first.
    let composite_tma = translate_up * rotate_90_deg * scale_half;

    let my_point: Point = [2.0, 0.0];
    
    // Apply the composed transformation to a point.
    let new_point = composite_tma * my_point; 

    println!("Transformed point: {:?}", new_point);
    assert_eq!(new_point[0], 0.0);
    assert_eq!(new_point[1], 2.0);
}

Purpose

This crate is a foundational component of the FractalAlgebra workspace. It provides the geometric building blocks for generating and exploring fractals and other systems based on affine transformations

Related Crates

This crate is part of a collection of crates by the same author: These include:-

  • MOMA
  • MOMA_simulation_engine
  • fractal_algebra
  • factorial_engine
  • fa_slow_ai
  • curvature
  • coheron

About

A lightweight and ergonomic Rust crate for defining, composing, and applying 2D affine transformations.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages