Files
enkou/enkou-shaders/src/transform.rs
T
bspeice 344ecc3450
CI / cargo fmt (push) Failing after 25s
CI / cargo test (GPU) (push) Has been cancelled
CI / cargo test (push) Has been cancelled
Add missing documentation
2026-06-27 11:02:19 -04:00

27 lines
857 B
Rust

//! # Transform
//!
//! Transforms are the "functions" in an iterated function system. They take in a point,
//! and generate a new point. For fractal flames, transforms are always affine,
//! but produce more interesting images once we add variations.
use bytemuck::{Pod, Zeroable};
use glam::{Affine2, Vec2};
/// Affine transform for use in the [`chaos_game`](crate::chaos_game).
#[derive(Copy, Clone, Pod, Zeroable)]
#[repr(C)]
pub struct Transform {
coefficients: Affine2,
}
impl Transform {
/// Create a new transform from an affine transformation matrix
pub fn new(coefficients: Affine2) -> Self {
Transform { coefficients }
}
/// Apply this transform to a point in IFS coordinates, producing a new point
pub fn transform_point(&self, point: Vec2) -> Vec2 {
self.coefficients.transform_point2(point)
}
}