From 9aae4d9c1ebdd31172fb353dfa526fd278824c98 Mon Sep 17 00:00:00 2001 From: Zhao Xin <7176466@qq.com> Date: Sun, 18 Dec 2022 00:07:31 +0800 Subject: [PATCH] update --- 11.风扇.html | 12 ------------ lib/utils.js | 11 +++++++++++ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/11.风扇.html b/11.风扇.html index ae30fca..526ebe9 100644 --- a/11.风扇.html +++ b/11.风扇.html @@ -126,18 +126,6 @@ line(200, 50, 280, 50); line(200, 50, 190, 60); textInfo(`风扇`, "2022-12-17", "赵海洋爸爸", 0); - - // let o = createVector(0, 0); - // let v = createVector(100, -100); - // let θ = createVector(1, 0).angleBetween(v); - // let r = v.mag(); - // let x = cos(θ) * r; - // let y = sin(θ) * r; - // translate(width / 2, height / 2); - // stroke(255); - // strokeWeight(4); - // point(0, 0); - // point(x, y); } function keyPressed() { diff --git a/lib/utils.js b/lib/utils.js index 7ba0570..417f47b 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -65,3 +65,14 @@ function star(x, y, radius1, radius2, npoints) { } endShape(CLOSE); } + +// cartesian to polar +function cartesianToPolara(x, y) { + let v = createVector(x, y); + return { r: v.mag(), θ: createVector(1, 0).angleBetween(v) }; +} + +// polar to cartesian +function polarToCartesian(r, θ) { + return { x: r * cos(θ), y: r * sin(θ) }; +}