That math problem, current attempt
Sep. 16th, 2011 10:18 amRemember the geometry problem I wrote about a couple of weeks ago? Well, I finally knuckled down and wrote the example.
I'm really flustered at times with graphical programming. First, the entirety of the problem must be translated from the origin into the positive plane, because (obviously) graphics displays don't handle well negative coordinates. Then comes the equally problematic issue that the Y-axis is flipped— positive means futher down— and trying to visualize the whole thing makes my brain ache. It's good for me, I suspect, in much the same way that poorly cooked spinach is still good for you. (Pan-wilted spinach over high heat with a balsamic reduction, on the other hand, is awesome.)
I tried last night to do the algorithm. It wasn't correct; I've gotten something wrong somewhere, and now I need to figure out where. What I did end up with was interesting. You must have Javascript enabled to see it run:
Experiment Six.
What was really sad was that I didn't have it animated, I just picked two angles (45 and 60). Sadly, at 45, the equation woks perfectly. I thought I had it nailed. Then I animated it.
Oh, well. Back to the drawing board.
[EDIT]: Whoa, that is cool. I kept watching the blue line, and noticed that it wasn't perfectly perpendicular to an axis when its intersection point crossed that axis; it was tangential near the axis rather than on it. It is perpendicular to the axis when the other line crosses it!
Huh. I wonder what this means...
Note to non-geeks and non-scientists: "I wonder what this means..." is the mark of my tribe. :-)
I'm really flustered at times with graphical programming. First, the entirety of the problem must be translated from the origin into the positive plane, because (obviously) graphics displays don't handle well negative coordinates. Then comes the equally problematic issue that the Y-axis is flipped— positive means futher down— and trying to visualize the whole thing makes my brain ache. It's good for me, I suspect, in much the same way that poorly cooked spinach is still good for you. (Pan-wilted spinach over high heat with a balsamic reduction, on the other hand, is awesome.)
I tried last night to do the algorithm. It wasn't correct; I've gotten something wrong somewhere, and now I need to figure out where. What I did end up with was interesting. You must have Javascript enabled to see it run:
Experiment Six.
What was really sad was that I didn't have it animated, I just picked two angles (45 and 60). Sadly, at 45, the equation woks perfectly. I thought I had it nailed. Then I animated it.
Oh, well. Back to the drawing board.
[EDIT]: Whoa, that is cool. I kept watching the blue line, and noticed that it wasn't perfectly perpendicular to an axis when its intersection point crossed that axis; it was tangential near the axis rather than on it. It is perpendicular to the axis when the other line crosses it!
Huh. I wonder what this means...
Note to non-geeks and non-scientists: "I wonder what this means..." is the mark of my tribe. :-)
no subject
Date: 2011-09-16 11:37 pm (UTC)My first guess is reversing the rise and run when computing the slope (correct when slope = 1), or having the wrong sign on the delta x that you're feeding into your quadratic. But that's the form of error I'd expect.
(Forgive the double post; I forgot to log in first. You can toss the anonymous version.)
no subject
Date: 2011-09-17 12:15 am (UTC)no subject
Date: 2011-09-17 12:14 am (UTC)diff -urN orig/arc_three.js working/arc_three.js --- orig/arc_three.js 2011-09-16 17:13:29.000000000 -0700 +++ working/arc_three.js 2011-09-16 17:13:11.000000000 -0700 @@ -51,7 +51,7 @@ ctx.lineTo(l2.x + cx, l2.y + cy); ctx.closePath(); ctx.stroke(); - m1 = l1.x / l1.y; + m1 = l1.y / l1.x; l3 = pos(ang2, r1); b1 = l3.y - l3.x * m1; ctx.beginPath();That's what you're looking for. You did x/y, when the slope is actually y/x ("rise over run"). Of course, at 45 degrees, they're equal, which is why your math worked out there.
no subject
Date: 2011-09-17 12:49 am (UTC)Thanks.