Miscellaneous > Programming & Networking
A programming challenge all up in your face.
pofnlice:
I can see your lips moving, but I can't hear a word you're saying...
worker201:
Haha, I finally figured out how to download that goddamm thing. It wasn't nearly as hard as I thought. Just right click and save as. I figured that since it was giving me 'attachment.php' that it was some intermediary thing. But it's the real file. I don't know why I couldn't get kittens.pdf, but oh well.
Anyway, here's the actual content of the file:
H_TeXMeX_H:
Well, then here's the output of kittens.m
--- Code: ---octave kittens.m
GNU Octave, version 2.9.8 (i686-redhat-linux-gnu).
Copyright (C) 2006 John W. Eaton.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTIBILITY or
FITNESS FOR A PARTICULAR PURPOSE. For details, type `warranty'.
Additional information about Octave is available at http://www.octave.org.
Please contribute if you find this software useful.
For more information, visit http://www.octave.org/help-wanted.html
Report bugs to (but first, please read
http://www.octave.org/bugs.html to learn how to write a helpful report).
total number of circles intersected
1
length of line w/o circles factored in
12.728
final path length after circles
15.999
--- End code ---
it was run with the data.dat containing the original example:
1
10
10
1
1
5 5 4
Looks like it might be working ... I'm just too lazy to check the answer
worker201:
Okay, here's some math that somebody can check for me:
k = slope, u = b-q, r = radius, (p,q) = center of circle
from Quirk's math example:
k^2x^2 + 2kux + u^2 = r^2 -x^2 + 2px - p^2
let j = u^2 - r^2 + p^2, therefore:
k^2x^2 + 2kux + j = -x^2 + 2px
k^2x^2 + x^2 + 2kux -2px + j = 0
x^2(k^2 + 1) + 2x(ku -p) + j = 0
to get it into canonical ax^2 + bx +c form:
let v = k^2 + 1, let w = ku - p, therefore:
vx^2 + 2wx + j = 0
a simple(!) quadratic should finish it from here, giving us values for x in terms of program constants. If my math is okay. Anybody want to check it?
mobrien_12:
It does seem to be working, here is some simplified data that I hand calculated
0
0
10
10
1
5 5 1
total number of circles intersected
1
length of line w/o circles factored in
14.142
final path length after circles
15.284
But I do find one problem. The formula I used for calculating the distance of the circle center from the line is from vector analysis, and assumes the line is actually next to the circle (essentially infinitly long, but defined by two points, and would work with Quirks original data and his original sketch). In the following case, the program thinks the circle is intercepted, and adds the extra path length for the circle.
This should be fixable in the If statement... any ideas?
[verwijderd door de beheerder]
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version