Miscellaneous > Programming & Networking

A programming challenge all up in your face.

<< < (8/24) > >>

mobrien_12:
Thoughts?

H_TeXMeX_H:
I dunno, it looks complex enough to work. How do you go about compiling it ?

worker201:

--- Quote from: mobrien_12 ---Thoughts?
--- End quote ---
I'm still trying to figure the math out (and figure out how to download shit that lies about its content in Firefox).  Once that is all over, I should be in a better position to evaluate your program, and perhaps compare it to whatever language mine gets written in (probably perl or C).

mobrien_12:
TeXMeX:  Octave is a scripting language.   All you have to do is put the contents into a file in the same directory as data.dat and call it "linecircles.m" or "kittens.m" or whatever.  

In that directory you would type "octave" on the bash command line and get the octave command line.  Then you would type "linecircles" or "kittens" or whatever and it would run the .m script.

Worker:  The idea of the math is as follows.  Find the distance between the center of the circle and the line, which according to vector analysis is along another line perpendicular to the first line.  If this is less than the radius of the circle then the line intersects the circle.  We then have a right triangle based on the radius to the intersection point and the distance from the center of the circle to the line.  You can use trig to find the angle, and then the length of the original line which we have to remove from the total path length (the chord) because we walk along the edge of the circle instead (the arclength).

From the angle we get the arc length which we add to the totaldistance.

If you subtract the chordlength from the arclength you get the extra path you take from walking around the circle.  You can just add this to the original line length and it makes the code a little more compact.

The attached figure should show some of this.

I'd really like to see this in a compiled language, but Octave is really really good for prototyping math algorithms.

[verwijderd door de beheerder]

H_TeXMeX_H:
Hmmm ... just tried it ... seems to work ok.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version