Author Topic: Bearing calculator for Elite Horizons surface flight  (Read 10630 times)

Rhaedas

  • Jr. Member
  • **
  • Posts: 72
Bearing calculator for Elite Horizons surface flight
« on: August 17, 2016, 05:41:48 PM »
A bit ago ravstar52 on Reddit made this post (https://www.reddit.com/r/EliteDangerous/comments/4wylhv/if_you_have_trouble_finding_coordinates_on/) for a program he developed to input your current coordinates displayed on your HUD when you're near a planet's surface and figure out which heading you should turn to in order to get to a desired known location. Someone else (CCninja86) took that code and made an online version.

My thought as a VoiceAttack user was, why not go the next step, have this voice entered and my ship tell me which way to turn? So I took ravstar52's code, modified it a bit more, and wrote some VA commands to talk to the exe. Was thinking about trying to make it a plugin, but this works very nicely as is. It should work all behind the scenes, no popping up or anything.

So how to get started - first get the executable from below, either download or compile it yourself. Make a new directory in the VoiceAttack directory (you already have VA if you're reading this, right?), naming it "BearingCalc". If you name it something else, you'll have to change the reference within one of the VA commands (calc heading). Put the exe in that directory. Then download the VA command profile at the link below and import it into VA. All the commands are under the category "Bearing", in case you need to look at them or remove them later.

That should be all you need to get started, no guarantees beyond saying it's been tested a number of times against the other two programs for numeric results. You can look at the commands to figure out what to say or to modify them. I set it up with the following commands:

"enter positions" or "set positions"

   This calls a routine to listen for each coordinate number, your current x and y first, then the target x and y. One requirement, you have to include either "positive" or "plus", "negative" or "minus" before the numbers as appropriate. If it doesn't get a good match to anything, it will prompt you three time before canceling out. For numbers, just use whole integers, don't worry about anything past the decimal point. I didn't try to set that up because I don't think it needs that much precision, plus it would have made entering more of a pain both for the user and the programming.
   
   When a number is understood, VA will read it back to you and ask for confirmation. "Confirm" or "correct" will work as set up. Three tries again before VA cancels out.
   
   If VA misheard you, "redo" starts over for that coordinate.
   
   Also in the coding in the <<prompt>> command I have a variable for "loop", set to 4. This is how many seconds you get between tries, adjust if you want it slower or faster, although too fast might make it miss your input often.
   
"enter current position" and "enter destination"
   
   These two allow you to enter the x/y of each point separately, maybe useful if things change. They don't call the calculation automatically, you'll need to use "calc heading" or "find heading" to do that. I just added these in to give a bit more flexibility in adjusting numbers.

"check heading"

   Same as above, but uses the previous destination inputted (it will read what it has stored), so you can check on your progress without reentering. If there was none entered, it will default to the above command.

"repeat heading"

   Just repeats the last calculated heading.

"read positions" or "read coordinates"

   Just reads what is currently in the position variables, more for testing than anything else.


Link for VoiceAttack commands: http://www.filedropper.com/bearingcalc_2

Link for exe to do the math: http://www.filedropper.com/bearingcalc_1, based on above linked post

For those cautious about running executables unseen, you can make it yourself same way I did, using this website: Online compiler http://www.onlinecompiler.net/ and inserting the following code, compiling, and then downloading the generated exe.

Source: Text file: http://www.filedropper.com/sourcecode

Code: [Select]
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <math.h>   // Allows use of atan2()
using namespace std;
 
//initilise ALL the things!
char bom;
float xStartingPosition;
float yStartingPosition;
float xEndingPosition;
float yEndingPosition;
float deltaX;
float deltaY;
int Heading;

//functions start here
 
int BearingCalculator(float xStart, float yStart, float xEnd, float yEnd) {
     
    deltaX = xStart - xEnd;                                                                         //Calculating the displacement in X
    deltaY = yStart - yEnd;                                                                         //Calculating the displacement in Y
     
    Heading = (atan2 (deltaY, deltaX) * (180/3.14159265));                                          //Calculating the bare Tan of the triangle
     
    if (Heading <= 0) {
        Heading = 360 + Heading;
    }
     
};
 
 
int main (int nNumberofArgs, char* pszArgs[])
{
    ifstream a_file ( "coordinates.txt" );
    if ( !a_file.is_open() ) {
ofstream e_file ( "heading.txt" );
e_file<< "error";
e_file.close();
return(0);
}
else {
a_file.get(bom);
a_file.get(bom);
a_file.get(bom);
    a_file>> xStartingPosition;
    a_file>> yStartingPosition;
    a_file>> xEndingPosition;
    a_file>> yEndingPosition;
    a_file.close();
}

BearingCalculator(xStartingPosition, yStartingPosition, xEndingPosition, yEndingPosition);     

    ofstream b_file ( "heading.txt" );
    b_file<< Heading;
    b_file.close();

    return 0;
}

sutex

  • Jr. Member
  • **
  • Posts: 91
Re: Bearing calculator for Elite Horizons surface flight
« Reply #1 on: August 26, 2016, 07:38:21 AM »
This is cool .. fired it up , and then looked at the coordinates for the TIP OFF which where

Lat 14.10

Lon-162.25

lol.. mmmm

also tried this  http://edbearingcalc.neocities.org/

 with this https://eddb.io/system/12978


OK  when I say enter destination ,  positive 6.5625 or whatever , it wont recognize it  NOT saying the 'point' , dot
After 40 attempts , it got 6.5 :).. training up the speech engine next

Also the I SAY 'positive;plus' .. variable was set to negative , I changed that to positive

Just trying to get it working.. BUT the interesting bit , is turning the spherical LAT LON into a Flat earth X Y
« Last Edit: August 26, 2016, 09:07:29 AM by sutex »

TheThingIs

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 278
    • HCS Voicepacks
Re: Bearing calculator for Elite Horizons surface flight
« Reply #2 on: August 28, 2016, 05:03:22 PM »
This works quite well. Well done and thanks for sharing.

surex, the instructions did say use whole integers and ignore anything after the . so that's probably why it wouldn't recognize 6.5625 :p
The Singularity profile - One profile to rule them all and at HCS we bound them ;)

You see, TheThingIs, eventually you'll be allright.

sutex

  • Jr. Member
  • **
  • Posts: 91
Re: Bearing calculator for Elite Horizons surface flight
« Reply #3 on: August 28, 2016, 06:53:27 PM »
Yes i did read that , and No I didn't day the dot , as mention in above post , but thanks for the feedback

Malic

  • Full Member
  • ***
  • Posts: 105
Re: Bearing calculator for Elite Horizons surface flight
« Reply #4 on: October 06, 2016, 10:42:33 PM »
Is there an updated download link?  The links int he first post are going to a file hosting 404

Exigeous

  • Newbie
  • *
  • Posts: 23
Re: Bearing calculator for Elite Horizons surface flight
« Reply #5 on: November 03, 2016, 10:24:03 PM »
Wow, this is totally fantastic!  I'm HORRIBLE at finding coordinates on a planet.  I recently went to visit the ruins in Elite 2.2 and spent over 20 minutes flying around trying to find the location.  I only finally succeeded by looking at a map someone had created with landmarks to find it, total fail with the coordinates.  I just set this up and it's fantastic, no more fumbling around in orbital cruise!!

-X