summaryrefslogtreecommitdiff
path: root/Planification_vol/src/planification/App.java
blob: cd51bc120fc959d27b5c98578d3d91c7c28b6b26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package planification;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class App {

	public static void main(String[] args) throws IOException {
		
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		
		double lat;
		double lon;
		double longueur;
		double largeur;
		double alt;
		double k;
		double nbWaypoint;
		
		String[] parts = line.split(" ");
		lat = Double.parseDouble(parts[0]);
		lon = Double.parseDouble(parts[1]);
		longueur = Double.parseDouble(parts[2]);
		largeur = Double.parseDouble(parts[3]);
		alt = Double.parseDouble(parts[4]);
		k = Double.parseDouble(parts[5]);
		nbWaypoint= Double.parseDouble(parts[6]);

		double zForEachWaypoint = alt / nbWaypoint;
		
		ArrayList<Waypoint> waypoints = new ArrayList<Waypoint>();
		
		double r = Math.max(longueur, largeur) + 3;
		double z = 0;
		double theta = 0;
		double gimbal = 0;
		
		for(int i = 0 ; i < nbWaypoint ; ++i) {
			
			theta = z / k;
			double x = r * Math.cos(theta);
			double y = r * Math.sin(theta);
			
			waypoints.add(new Waypoint(x, y, z, theta, gimbal, true));
			System.out.println("x = " + x + " y = " + y + " z = " + z + " t = " + theta);
			
			z += zForEachWaypoint;
			
		}

		z = alt;
		for(int i = 0 ; i < nbWaypoint ; ++i) {
			
			theta = z / k + 180;
			double x = r * Math.cos(theta);
			double y = r * Math.sin(theta);
			
			waypoints.add(new Waypoint(x, y, z, theta, gimbal, true));
			System.out.println("x = " + x + " y = " + y + " z = " + z + " t = " + theta);
			
			z -= zForEachWaypoint;
			
		}
		
		BufferedWriter writer = new BufferedWriter(new FileWriter("./flightplan.txt"));
		for(int i = 0 ; i < waypoints.size() ; ++i) {
			Waypoint wp = waypoints.get(i);
			String s = wp.getLat() + ":" + wp.getLon() + ":" + wp.getAlt() + ":" + wp.getDirection() + ":" + wp.getGimbal() + ":" + wp.isPhoto() + "\n";
		    writer.write(s);
		}
	    writer.close();

	}

}