Logarithmic spiral appears inverted

139 Views Asked by At

I'm learning to code the equation for a logarithmic spiral for a graphics visualization. However, it appears to be inverted with the radius getting smaller (rather than larger) toward the outside of the curve. How can I invert the result so the radius gets larger as the curve moves outward?

var theta = 1; // begin at theta 1
for (var p = 0; p < particleCount; p++) {
    // LOG SPIRAL SHAPE
    var a = 500; // a constant
    var b = 0.2; // another constant
    var pX = a * Math.cos(theta) * Math.log(b * theta);
    var pY = a * Math.sin(theta) * Math.log(b * theta);
    theta += 1; // increment theta
    // place an image at pX,pY and repeat

Since a picture is worth a thousand words (or lines of code), here is the result:

enter image description here

1

There are 1 best solutions below

0
On BEST ANSWER

Replace Math.log(b * theta) by Math.exp(b * theta) and things should agree with the formulas from the article you referenced.