Skip to content

Instantly share code, notes, and snippets.

View RobertBrewitz's full-sized avatar

Robert Borg RobertBrewitz

View GitHub Profile
@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);
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//