diff --git a/src/trap/filters.rs b/src/trap/filters.rs index f2c780a..313f3d5 100644 --- a/src/trap/filters.rs +++ b/src/trap/filters.rs @@ -313,6 +313,14 @@ impl Filter for PincushionFilter { let projected_positions: Vec = points.points.iter().map(|point| { let p = point.position; + + + // formula by Ilya Sinenko: https://hackernoon.com/galvo-scanner-pillow-and-barrel-distortions-correction + // x_angle = atan(x_cord / (sqrt(pow(d,2)+pow(y_cord,2))+e)) + + let x = (p[0] / (p[1].abs() + self.k_x )).atan(); + return [x, p[1]]; + let mut radius = (p[0].powi(2) + p[1].powi(2)).sqrt(); let new_position = if radius > 0. { let theta = p[1].atan2(p[0]);