Data Mapping Magnetic

edited December 2015 in Questions about Code

Hello,

I have data mapping magnetic fields in eight-story building. My Data folder contains excel sheets of magnetic field in each floor. I need to assign particle system to each floor and connect the X-Axis, Y-Axis and Z-axis from the excel sheets to the movement of the particles. Here is a link to what I have so far: https://www.dropbox.com/s/ham79242z4nmhp0/magnetic_field_Multiple_Tables_1.zip?dl=0

Help!

Answers

  • Help with what?

    Please describe where you are stuck...

    What have you tried?

  • I can’t figure out how to connect the data to the particles.

  • edited December 2015 Answer ✓

    well, when you want one particle for each line of the csv-files

    you need to loop over the csv (or the tables) and use the data to setup one particle

    to do

    so instead of

    for (int i = 0; i<particlesCollection.length; i++) {

    you loop over the table.

    AND to do

    instead of

    particlesCollection [i] = new particles (random(0, 200), random(0, 200), random(0, 2), random(0, 1));
    

    you need

        float XAxis = row.getInt("XAxis"); 
        float YAxis = row.getInt("YAxis"); 
        float ZAxis = row.getFloat("ZAxis"); 
    
        particlesCollection [i] = new particles (XAxis, YAxis, ZAxis , random(0, 1));
    

    or so....

  • I get an error telling me that it cannot find anything named "row".

  • Answer ✓

    it's pseudo code

    I was just copying stuff from your code, from another place

    of course you need to copy the context and make the adjustments

  • Answer ✓

    when you want as many particles as you have measuring data / lines

    you need an ArrayList for the particles where you don't have a fixed maximum number but can just add more and more particles (since you don't know their number)

    when you want as many particles as you have measuring data / lines : you must loop over the measuring data / lines and generate the particle here with new and put them into the ArrayList with add:

    ArrayList<Particle> particles = new ArrayList(); 
    
    Particle newParticle = new Particle(......................); 
    particles.add(newParticle);
    
  • since you have the csv for each floor separately, consider to have a separate ArrayList of particles for each floor...

    or have an array of ArrayLists of particles for each floor...

  • Ok Thank you ! I will try to do that ...

  • How do I make an array of ArrayLists ?

  • _vk_vk
    edited December 2015

    How do I make an array of ArrayLists ?

    ArrayList <ArrayList <String>> s = new ArrayList < ArrayList<String>>();
    
    ArrayList <String> t = new ArrayList<String>();
    
    t.add("one");
    t.add("two");
    s.add(t);
    println(s.get(0).get(1));
    s.get(0).add("three");
    println(s.get(0).get(2));
    println(s.get(0));  
    
  • Ops sorry, I mis read that's an ArrayList of Arraylists...

  • ArrayList[] s = new ArrayList[4];
    
    ArrayList <String> t = new ArrayList<String>();
    
    t.add("one");
    t.add("two");
    
    s[0] = t;
    println(s[0].get(1));
    
    s[0].add("three");
    println(s[0].get(2));
    println(s[0]); 
    
Sign In or Register to comment.