From 20f3a92f1c5ddecb565634237e33b321e846ad5d Mon Sep 17 00:00:00 2001 From: Gaspard Coulet Date: Wed, 28 Apr 2021 23:08:21 +0200 Subject: Initial commit --- Planification_vol/src/planification/App.java | 79 ++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Planification_vol/src/planification/App.java (limited to 'Planification_vol/src/planification/App.java') diff --git a/Planification_vol/src/planification/App.java b/Planification_vol/src/planification/App.java new file mode 100644 index 0000000..cd51bc1 --- /dev/null +++ b/Planification_vol/src/planification/App.java @@ -0,0 +1,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 waypoints = new ArrayList(); + + 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(); + + } + +} -- cgit v1.2.3