diff --git a/4-12.html b/4-12.html index d1f45c6..a24136a 100644 --- a/4-12.html +++ b/4-12.html @@ -164,28 +164,61 @@ ctx.beginPath(); ctx.arc(xPos, yPos, 100, 0, Math.PI * 2); ctx.stroke(); - for (i = 0; i < n; i++) + if (m % 2 == 0) { - if (2 * w * Math.sin(Math.PI * m / n) > 0.0001) + mn = Math.floor(m / 2); + console.log("cos" + mn.toString()); + for (i = 0; i < n; i++) { - var theta = Math.PI * 2 * i / n; - theta += Math.cos(i * 2 * Math.PI * m / n) * amp * Math.cos(2 * w * Math.sin(Math.PI * m / n) * t); - var theta2 = Math.PI * 2 * (i + 1) / n; - theta2 += Math.cos((i+1) * 2 * Math.PI * m / n) * amp * Math.cos(2 * w * Math.sin(Math.PI * m / n) * t); - ctx.beginPath(); - ctx.arc(xPos + 100 * Math.cos(theta), yPos + 100 * Math.sin(theta), 10, 0, Math.PI * 2); - ctx.fill(); - connectTwoTheta(theta, theta2); - } else + if (2 * w * Math.sin(Math.PI * mn / n) > 0.0001) + { + var theta = Math.PI * 2 * i / n; + theta += Math.cos(i * 2 * Math.PI * mn / n) * amp * Math.cos(2 * w * Math.sin(Math.PI * mn / n) * t); + var theta2 = Math.PI * 2 * (i + 1) / n; + theta2 += Math.cos((i+1) * 2 * Math.PI * mn / n) * amp * Math.cos(2 * w * Math.sin(Math.PI * mn / n) * t); + ctx.beginPath(); + ctx.arc(xPos + 100 * Math.cos(theta), yPos + 100 * Math.sin(theta), 10, 0, Math.PI * 2); + ctx.fill(); + connectTwoTheta(theta, theta2); + } else + { + var theta = Math.PI * 2 * i / n; + theta += Math.cos(i * 2 * Math.PI * mn / n) * amp * w * t; + var theta2 = Math.PI * 2 * (i + 1) / n; + theta2 += Math.cos((i+1) * 2 * Math.PI * mn / n) * amp * w * t; + ctx.beginPath(); + ctx.arc(xPos + 100 * Math.cos(theta), yPos + 100 * Math.sin(theta), 10, 0, Math.PI * 2); + ctx.fill(); + connectTwoTheta(theta, theta2); + } + } + } else + { + mn = Math.floor(m / 2); + console.log("sin" + mn.toString()); + for (i = 0; i < n; i++) { - var theta = Math.PI * 2 * i / n; - theta += Math.cos(i * 2 * Math.PI * m / n) * amp * w * t; - var theta2 = Math.PI * 2 * (i + 1) / n; - theta2 += Math.cos((i+1) * 2 * Math.PI * m / n) * amp * w * t; - ctx.beginPath(); - ctx.arc(xPos + 100 * Math.cos(theta), yPos + 100 * Math.sin(theta), 10, 0, Math.PI * 2); - ctx.fill(); - connectTwoTheta(theta, theta2); + if (2 * w * Math.sin(Math.PI * mn / n) > 0.0001) + { + var theta = Math.PI * 2 * i / n; + theta += Math.sin(i * 2 * Math.PI * mn / n) * amp * Math.cos(2 * w * Math.sin(Math.PI * mn / n) * t); + var theta2 = Math.PI * 2 * (i + 1) / n; + theta2 += Math.sin((i+1) * 2 * Math.PI * mn / n) * amp * Math.cos(2 * w * Math.sin(Math.PI * mn / n) * t); + ctx.beginPath(); + ctx.arc(xPos + 100 * Math.cos(theta), yPos + 100 * Math.sin(theta), 10, 0, Math.PI * 2); + ctx.fill(); + connectTwoTheta(theta, theta2); + } else + { + var theta = Math.PI * 2 * i / n; + theta += Math.cos(i * 2 * Math.PI * mn / n) * amp * w * t; + var theta2 = Math.PI * 2 * (i + 1) / n; + theta2 += Math.cos((i+1) * 2 * Math.PI * mn / n) * amp * w * t; + ctx.beginPath(); + ctx.arc(xPos + 100 * Math.cos(theta), yPos + 100 * Math.sin(theta), 10, 0, Math.PI * 2); + ctx.fill(); + connectTwoTheta(theta, theta2); + } } } } diff --git a/5-15.html b/5-15.html new file mode 100644 index 0000000..ddcd2a9 --- /dev/null +++ b/5-15.html @@ -0,0 +1,170 @@ + + + + + Problem 5-15 + + + + + + Your browser does not support the HTML5 canvas tag. + + + +

+ This work is licensed under + CC BY-NC-ND 4.0

+ \ No newline at end of file diff --git a/5-16.html b/5-16.html new file mode 100644 index 0000000..149b4c9 --- /dev/null +++ b/5-16.html @@ -0,0 +1,174 @@ + + + + + Problem 5-16 + + + + + + Your browser does not support the HTML5 canvas tag. + + + +

+ This work is licensed under + CC BY-NC-ND 4.0

+ \ No newline at end of file