Generate Tweens from CSV file with Ijeomamotion library
in
Contributed Library Questions
•
6 months ago
Hello,
I am currenty trying to write a program that draw lines from a center and outwards, where the length, angle (in radians), start time, flight time and finish time (seconds) of all lines are in a CSV file.
The problem I am having is that I can't figure out how to get the Ijeomamotion library (or any other library) to read the file and generate as many tweens as there are entries in the CSV file. And then draw the lines over the course of 24 hours.
Anyone have some ideas of how to do this?
All help is greatly appreciated.
Tegel_a2.csv:
- 478,3.4732,24376,2024,26400
- 6402,2.6878,186,27114,27300
- 1616,0.4014,20456,6844,27300
- 1109,0.9599,23503,4697,28200
- 691,5.3756,24673,2927,27600
- 477,3.4034,24980,2020,27000
- 511,4.0666,25136,2164,27300
- 504,4.4506,25165,2135,27300
- 478,3.4732,25276,2024,27300
- 525,4.66,25376,2224,27600
- 523,5.1487,25385,2215,27600
- 377,4.2586,25403,1597,27000
and so on for a couple of hundred lines.
This is the code without tweens, so you can see the principle of the program:
- String[] lines;
- int index, last, lastTime;
- float angle, distance, takeoff, flighttime, touchdown, sofar, dist;
- void setup() {
- size(1600, 1000);
- background(255);
- stroke(0);
- smooth();
- lines = loadStrings("Tegel_a2.csv");
- }
- void draw() {
- float time = (hour()*60*60)+(minute()*60)+second();
- if (index < lines.length) {
- // Split the input file by comma
- String[] pieces = split(lines[index], ',');
- distance = float(pieces[0]);
- angle = float(pieces[1]);
- takeoff = float(pieces[2]);
- flighttime = float(pieces[3]);
- touchdown = float(pieces[4]);
- if((distance/flighttime)*(time-takeoff) > 0) {
- sofar = (distance/flighttime)*(time-takeoff);
- } else {
- sofar = 0;
- }
- if (time >= takeoff && time<=touchdown ) {
- lineAngle(width/2, height/2, angle, sofar);
- println( " Angle in radians: "+angle+" Distance in km: "+distance+" sofar in km: "+sofar);
- }
- index = index + 1;
- }else{
- if ( millis() - lastTime > 10000 ) {
- index = 0;
- background(255);
- println("10 sec reset!");
- lastTime = millis();
- }
- } //END IF ELSE
- } //END DRAW
- void lineAngle(int x, int y, float angle, float length)
- {
- line(x, y, x+cos(angle)*(length/6), y-sin(angle)*(length/6));
- }
1