calculate geolocation distance btwn current pos and target?

0 favourites
  • 13 posts
From the Asset Store
Aim carefully a shoot the ball at the target to earn scores!
  • How to find out distance between current geolocation coordinate and target geolocation coordinate on every tick? I want to show user how much far (in metres) he is from target object every time he walks towards the target object.

    Any help plz

  • What unit is your coordinate returned in? Or are you having trouble getting that?

  • i m getting lat and long for current and destination positions. I want it to show in metres only.

  • Lat. and Long. are not in meters. They are in degrees or other units.

  • Lat. and Long. are not in meters. They are in degrees or other units.

    yes how to convert them to readable form and use it to calculate distance between two points?

  • Haversine formula ?

    [quote:39itocod]Haversine formula:

    a = sin²(?f/2) + cos f1 · cos f2 · sin²(??/2)

    c = 2 · atan2( va, v(1-a) )

    d = R · c

    where f is latitude, ? is longitude, R is earth’s radius (mean radius = 6,371km);

    note that angles need to be in radians!

    Radians = Degrees * PI / 180

    JavaScript:

    var R = 6371e3; // metres

    var f1 = lat1.toRadians();

    var f2 = lat2.toRadians();

    var ?f = (lat2-lat1).toRadians();

    var ?? = (lon2-lon1).toRadians();

    var a = Math.sin(?f/2) * Math.sin(?f/2) +

    Math.cos(f1) * Math.cos(f2) *

    Math.sin(??/2) * Math.sin(??/2);

    var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));

    var d = R * c;

  • Haversine formula ?

    [quote:30ofq63l]Haversine formula:

    a = sin²(?f/2) + cos f1 · cos f2 · sin²(??/2)

    c = 2 · atan2( va, v(1-a) )

    d = R · c

    where f is latitude, ? is longitude, R is earth’s radius (mean radius = 6,371km);

    note that angles need to be in radians!

    Radians = Degrees * PI / 180

    JavaScript:

    var R = 6371e3; // metres

    var f1 = lat1.toRadians();

    var f2 = lat2.toRadians();

    var ?f = (lat2-lat1).toRadians();

    var ?? = (lon2-lon1).toRadians();

    var a = Math.sin(?f/2) * Math.sin(?f/2) +

    Math.cos(f1) * Math.cos(f2) *

    Math.sin(??/2) * Math.sin(??/2);

    var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));

    var d = R * c;

    Thanks a lot..but im just starter with construct 2..c.ant understand so much math. any simpler solution will be big big help. thanks in advance.

  • ..any simpler solution will be big big help.

    True..so true..

    here is a small example, with Browser.ExecJS : browserGeoDist.capx

    (tested only in Chrome)

    I tried to "translate" from javascript to C2 events...

    a = sin²(?f/2) + cos f1 · cos f2 · sin²(??/2)
    c = 2 · atan2( va, v(1-a) )
    d = R · c[/code:1lgto0pk]
    
    but there is [b]no[/b] function [b]atan2(Y,X)[/b] in [b]C2[/b]?!!
    
    ....[i]or I  overlooked something?[/i]
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Instead of atan2(y,x) use angle(0,0,X,y).

  • Instead of atan2(y,x) use angle(0,0,X,y).

    Thanks R0J0hound !

    so..from

    atan2( va, v(1-a) )[/code:1j3jm382]
    to
    [code:1j3jm382]angle(0,0,sqrt(1-a),sqrt(a))*(pi/180)[/code:1j3jm382]
    
    cool  
    --------------------------------------------
    here:
    
    [url=https://www.distancecalculator.net/from-london-to-paris]Distance between London and Paris[/url]
    
    [img="http://lookpic.com/O/i2/1985/ifAlBArf.png"]
    
    [url=https://app.box.com/s/kvebdn4zq17meidk2gdsg2liuml0qlu9]haversine2C2.capx[/url]
  • thanks a lot guys...it works nicely. But how to display the distance in a map.... can we create a custom map ? for example: pokemon go created own map with green colors. is that possible?

  • Pokémon Go use Google Maps API...

    check rexrainbow google map plugin&behavior

  • Pokémon Go use Google Maps API...

    check rexrainbow google map plugin&behavior

    Hi ,

    I am aware that Pokemon go uses google map api...but the floor image they use is custom green which doesnt show place names etc. How to do that? what logic is used to create that floor image.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)