Skip to content

Instantly share code, notes, and snippets.

@raphlinus
raphlinus / neo_flatten.rs
Created November 12, 2025 04:43
prototype SIMD implementation of new flatten algorithm
use fearless_simd::{Level, Select, Simd, SimdInto, dispatch, f32x4};
#[repr(C)]
#[derive(Clone, Copy, Debug)]
struct Point {
x: f32,
y: f32,
}
impl Point {
@raphlinus
raphlinus / kbound.rs
Created November 14, 2025 05:04
Compute curvature bounds for cubic Bézier using interval arithmetic
use kurbo::{CubicBez, ParamCurveDeriv};
/// Compute bounds on curvature
pub fn kbound(c: CubicBez) -> (f64, f64) {
let q = c.deriv();
let p1xp0 = q.p1.to_vec2().cross(q.p0.to_vec2());
let p2xp0 = q.p2.to_vec2().cross(q.p0.to_vec2());
let p2xp1 = q.p2.to_vec2().cross(q.p1.to_vec2());
let c0 = 2. * p1xp0;
let c1 = 2. * (p2xp0 - 2.0 * p1xp0);
@raphlinus
raphlinus / half_experiment.patch
Created November 19, 2025 23:22
Experiment with widen/narrow associated types
commit 49309841ba5cb7db0989a87c0a1d4b2947f02314
Merge: 3abe852 de4ec3f
Author: Raph Levien <[email protected]>
Date: Wed Jun 11 08:12:42 2025 -0700
On gen2: half experiment
diff --cc fearless_simd/src/generated/simd_trait.rs
index 875ccad,875ccad..544068b
--- a/fearless_simd/src/generated/simd_trait.rs
@raphlinus
raphlinus / foozle_count.rs
Created April 5, 2026 21:31
Example of AI-generated docstring
/// A structure representing a system that tracks "foozles".
pub struct FoozleTracker {
/// The current count of foozles observed.
/// We use u64 to provide a massive range (0 to 18,446,744,073,709,551,615),
/// minimizing the risk of counter overflow in most practical applications.
pub foozle_count: u64,
}
impl FoozleTracker {
/// Creates a new FoozleTracker starting at zero.