Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: 3 Dimensional repelling particle simulation

by JPaul (Hermit)
on Mar 19, 2002 at 05:19 UTC ( [id://152656]=note: print w/replies, xml ) Need Help??


in reply to Re: 3 Dimensional repelling particle simulation
in thread 3 Dimensional repelling particle simulation

Greetings again,
I have asked this question wrong - and indeed, was somewhat harsh to the first reply.
You are quite right - this is, technically, not a perl question per se - but since this code will be implemented in perl, I hoped it would be close enough that I would be able to arouse the brains of others into helping me with this conundrum

I felt that the question posed showed enough complexity that a very simple "How to use foreach" was clearly not what I wanted in an answer thus the short, sharp nature of my reply.
HOWEVER in saying that, the fact that jhanna gave me an explanation that quite possibly a number of monks would say 'What a moron, go read a book' is a good thing.
So, thanks jhanna, my apologies for being short - but that wasn't quite the answer I was looking for.

I'm going to restate my question like I should have in the first place. The possibly misleading manner I asked it in was how the simulation was explained to me:
I was playing around with making my own IP map. Nothing large, just my local network for a laugh and to show off. The nodes are the IP addresses, the links are the routes between them.
You do multiple traceroutes, from multiple locations to create an interlinked "map" (Which I have neatly stored in a MySQL DB). The "distance" between nodes is calculated from the average "distance", in milliseconds, from IP addresses in the traceroute.
The links are like springs, their repulsion charge is the given distance, and when set going in the simulation, the nodes will push each other apart in such a way that they place themselves roughly in space to equate the "distances" from other IP addresses...
I want all the co-ordinates, after the simulation has run and spaced them accordingly, to dump into POVray.

I hope this is more clear,
JP,
-- Alexander Widdlemouse undid his bellybutton and his bum dropped off --

Replies are listed 'Best First'.
•Re: Re: Re: 3 Dimensional repelling particle simulation
by merlyn (Sage) on Mar 19, 2002 at 05:57 UTC
    Well, I'm no theoretical mathematician, but I think your problem is going to involve compromise on some level. In fact, for even three nodes, it's possible that the "link distance" is insolvable, if the ping times between A and B exceed the sum of the ping times from A to C and C to B. So whatever algorithm you choose, it's going to involve some sort of first order approximation, and a satisfaction threshold, rather than some rigid math. Maybe that will help decide how to do it.

    -- Randal L. Schwartz, Perl hacker

      Thanks for your input - I had already resigned myself to that however.
      In this case, 'near enough is close enough' - it will be graphically displayed after all, I doubt people are going to try and take a ruler to it and tell me off for being a few millimetres off!

      JP,
      -- Alexander Widdlemouse undid his bellybutton and his bum dropped off --

Re: Re: Re: 3 Dimensional repelling particle simulation
by zengargoyle (Deacon) on Mar 19, 2002 at 05:55 UTC

    Randomly (or equally for that matter) place them on the surface of a very very large sphere. The force between particles is the distance minus the ping. Scale it by a factor of 100 or so (mass of particle). That will be your acceleration (distance and acceleration are vectors remember) for that link. Calculate one for each link the particle has. Store the acceleration per link for later. Go to the next particle and repeat. Note acceleration(a->b) == -acceleration(b->a) if all particles have equal mass. Once you have all of the acceleration vectors for each particle-particle link visit each particle, sum it's acceleration vector (should point roughly towards 0,0,0) and move the particle acceleration times time (assume 1). Repeat. You will have to tune it a bit, what to use for mass, how far apart to start, maybe modify the acceleration calculation to push out harder when particles are too close than it would pull when the particles were too far apart. Over time/iterations it just might converge ;). The usual method would be to stop when the accelerations are all under a certain amount (should approach zero).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://152656]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-03-29 06:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found