Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

particle physics in java 1.2

  • 02-05-2001 11:10pm
    #1
    Registered Users, Registered Users 2 Posts: 2,281 ✭✭✭


    im making an applet (for *fun* not for hw) that has loads of particles bouncing around randomly, with variable gravity and bouncyness etc...

    currently the particles only bounce off the walls, not off each other.

    all the particles are in an array of particles, and i want to constantly check are they touching each other.

    can anyone think of a way to check all the array members against each other, but not check twice, ie:
    for an array of lenght 4:

    a checks b
    a checks c
    a checks d

    b no check a
    b checks c
    b checks d

    d no check a
    d no check b
    d checks c

    ?

    - Dead Bank Clerk -
    [clergy]Altar Boy
    "Build a man a fire, and he'll
    be warm for a day. Set a man on
    fire, and he'll be warm for the
    rest of his life."


Comments

  • Moderators, Social & Fun Moderators Posts: 10,501 Mod ✭✭✭✭ecksor


    Two nested for loops?

    As in, outside for loop loops from the first particle to the second last particle. The second for loop loops from the element after the current particle in the outer loop to the last particle. Compare them inside the inside loop.

    I.E.
    for( i = 0; i < (particlearray.length - 2) ; i++ ) {
        for( j = (i + 1); j < (particlearray.length - 1); j++) {
            //compare particlearray[i] and particlearray[j]
        }
    }
    


  • Registered Users, Registered Users 2 Posts: 7,626 ✭✭✭smoke.me.a.kipper


    eek.gif
    marc, go to bed.

    and stop making my not so leet java'ing skillz look bad. christ. i can't even fathom to think what your on about there. eek.gif

    eek.gif


  • Registered Users, Registered Users 2 Posts: 2,281 ✭✭✭DeadBankClerk


    SMAK BOTTOM!

    thanks a million x_or, ill try it tommorrow.

    btx, whats the best java editor to use? i have j++ in college and i like it (shudder), becasue its what i learned on.

    i want to get one at home, and everyone tells me j++ is ****e.
    ?


    <EDIT> omg it put *'s over the word "poo" which i spet with a "1" instead of an "i". they are out to stop us eek.gif </edit>

    [This message has been edited by DeadBankClerk (edited 03-05-2001).]


  • Moderators, Social & Fun Moderators Posts: 10,501 Mod ✭✭✭✭ecksor


    I like vim/gvim for editing java (or anything else for that matter), but that's not everyone's cup of java (look, I made a funny, *giggle* ... *ahem*)

    I've heard lots of people rave on about editplus (http://www.editplus.com), but I've yet to try it.


  • Registered Users, Registered Users 2 Posts: 16,414 ✭✭✭✭Trojan


    If we're talking text editors on windows, then UltraEdit has my vote, lovely. ( www.ultraedit.com )

    VC++ is pretty handy as a text editor too once you set it up...

    Al.


  • Advertisement
  • Closed Accounts Posts: 215 ✭✭Skeptic1


    This does the same thing, but may be easier to follow.
    for (i = 1, i &lt; particleArray.length, i++)
       for (j = 0, j &lt; i, j++) {
          // compare particleArray[i] with particleArray[j]
       }
    
    The inner loop gets longer as the outer loop progresses. The way to visualise this might be as a matrix:
       0 1 2 3 4 5 ...  j
     0 
     1 x 
     2 x x 
     3 x x x
     4 x x x x
     5 x x x x x
     .
     .
     i
    
    where x represents the comparison to be made.

    For an editor, I like forte, an editor written in java2 and free from Sun.

    [This message has been edited by Skeptic1 (edited 03-05-2001).]


  • Closed Accounts Posts: 53 ✭✭Zee Dude


    Borland JBuilder 4.0 is the best IDE for java around, I think you can get a free version of it from their website.

    Good for JSP's as well.


  • Registered Users, Registered Users 2 Posts: 932 ✭✭✭yossarin


    best: (imho) winedit. no fancy features. its just an enhanced text editor.

    J++ has a habit of corrupting files, and also forces you to make a 'project' out of your files, which is utterly unnecessary...sigh

    i head good things about JBuilder though.


  • Closed Accounts Posts: 33 Robbie Burke


    I like First Page 2000 for nearly all my coding... free from www.evrsoft.com ...its main feature is an extremely good HTML editor and a hyped up text editor, but, I like it. Its also good for Perl editing.


Advertisement