?

Log in

No account? Create an account
entries friends calendar profile Elf Sternberg's Pendorwright Projects Previous Previous Next Next
That math problem, current attempt - Elf M. Sternberg
elfs
elfs
That math problem, current attempt
Remember 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. :-)
4 comments or Leave a comment
Comments
theerik From: theerik Date: September 16th, 2011 11:37 pm (UTC) (Link)
It's very close - the intersection point is perfect, the slope is correct at the (modulo pi/4) points and right angles at (modulo pi/2). This means that you almost certainly have a sign reversed or a 1/x error.

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.)
zanfur From: zanfur Date: September 17th, 2011 12:15 am (UTC) (Link)
Your first guess was correct. :-)
zanfur From: zanfur Date: September 17th, 2011 12:14 am (UTC) (Link)
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.
elfs From: elfs Date: September 17th, 2011 12:49 am (UTC) (Link)
Aarrrrgh! Head -> DESK! Ouch.

Thanks.
4 comments or Leave a comment