MCPcopy Create free account
hub / github.com/Notgnoshi/generative / to_polar

Function to_polar

tools/transform.rs:232–239  ·  view source on GitHub ↗
(coord: Coord)

Source from the content-addressed store, hash-verified

230}
231
232fn to_polar(coord: Coord) -> Coord {
233 let r = f64::sqrt(coord.x.powi(2) + coord.y.powi(2));
234 let mut theta = f64::atan2(coord.y, coord.x);
235 if theta < 0.0 {
236 theta += 2.0 * std::f64::consts::PI;
237 }
238 coord! { x: r, y: theta}
239}
240
241fn scale_range(src: &[f64; 2], dst: &[f64; 2], v: f64) -> f64 {
242 (dst[1] - dst[0]) * (v - src[0]) / (src[1] - src[0]) + dst[0]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected