MCPcopy Create free account
hub / github.com/donkeyteethUX/iced_plot / catmull_rom_point

Function catmull_rom_point

examples/interactive_spline.rs:172–189  ·  view source on GitHub ↗
(p0: [f64; 2], p1: [f64; 2], p2: [f64; 2], p3: [f64; 2], t: f64)

Source from the content-addressed store, hash-verified

170}
171
172fn catmull_rom_point(p0: [f64; 2], p1: [f64; 2], p2: [f64; 2], p3: [f64; 2], t: f64) -> [f64; 2] {
173 let t2 = t * t;
174 let t3 = t2 * t;
175
176 let x = 0.5
177 * ((2.0 * p1[0])
178 + (-p0[0] + p2[0]) * t
179 + (2.0 * p0[0] - 5.0 * p1[0] + 4.0 * p2[0] - p3[0]) * t2
180 + (-p0[0] + 3.0 * p1[0] - 3.0 * p2[0] + p3[0]) * t3);
181
182 let y = 0.5
183 * ((2.0 * p1[1])
184 + (-p0[1] + p2[1]) * t
185 + (2.0 * p0[1] - 5.0 * p1[1] + 4.0 * p2[1] - p3[1]) * t2
186 + (-p0[1] + 3.0 * p1[1] - 3.0 * p2[1] + p3[1]) * t3);
187
188 [x, y]
189}
190
191fn nearest_control_point_index(
192 control_points: &[[f64; 2]],

Callers 1

sample_catmull_romFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected