Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 849571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:07:29+00:00 2026-05-15T07:07:29+00:00

I’m constructing a geolocation based application and I’m trying to figure out a way

  • 0

I’m constructing a geolocation based application and I’m trying to figure out a way to make my application realise when a user is facing the direction of the given location (a particular long / lat co-ord). I’ve got the math figured, I just have the triangle to construct.

//UPDATE

So I’ve figured out a good bit of this…

Below is a method which takes in a long / lat value and attempts to compute a triangle finding a point 700 meters away and one to its left + right. It’d then use these to construct the triangle. It computes the correct longitude but the latitude ends up somewhere off the coast of east Africa. (I’m in Ireland!).

public void drawtri(double currlng,double currlat, double bearing){

    bearing = (bearing < 0 ? -bearing : bearing);

    System.out.println("RUNNING THE DRAW TRIANGLE METHOD!!!!!");
    System.out.println("CURRENT LNG" + currlng);
    System.out.println("CURRENT LAT" + currlat);
    System.out.println("CURRENT BEARING" + bearing);

    //Find point X(x,y)
    double distance = 0.7; //700 meters.
    double R = 6371.0; //The radius of the earth.
    //Finding X's y value.

    Math.toRadians(currlng);
    Math.toRadians(currlat);
    Math.toRadians(bearing);

    distance = distance/R;
    Global.Alat = Math.asin(Math.sin(currlat)*Math.cos(distance)+ 
            Math.cos(currlat)*Math.sin(distance)*Math.cos(bearing));
    System.out.println("CURRENT ALAT!!: " + Global.Alat);
    //Finding X's x value.
    Global.Alng = currlng + Math.atan2(Math.sin(bearing)*Math.sin(distance)
            *Math.cos(currlat), Math.cos(distance)-Math.sin(currlat)*Math.sin(Global.Alat));
    Math.toDegrees(Global.Alat);
    Math.toDegrees(Global.Alng);


    //Co-ord of Point B(x,y)
    // Note: Lng = X axis, Lat = Y axis.
    Global.Blat = Global.Alat+ 00.007931;
    Global.Blng = Global.Alng;

    //Co-ord of Point C(x,y)
    Global.Clat = Global.Alat  - 00.007931;
    Global.Clng = Global.Alng;

    }

From debugging I’ve determined the problem lies with the computation of the latitude done here..

 Global.Alat = Math.asin(Math.sin(currlat)*Math.cos(distance)+ 
        Math.cos(currlat)*Math.sin(distance)*Math.cos(bearing));

I have no idea why though and don’t know how to fix it. I got the formula from this site..

http://www.movable-type.co.uk/scripts/latlong.html

It appears correct and I’ve tested multiple things…

I’ve tried converting to Radians then post computations back to degrees, etc. etc.

Anyone got any ideas how to fix this method so that it will map the triangle ONLY 700 meters in from my current location in the direction that I am facing?

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T07:07:29+00:00Added an answer on May 15, 2026 at 7:07 am

    Problem was no matter what I piped in java would output in Radians, Trick was to change everything to Radians and then output came in radians, convert to degrees.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I know there's a lot of other questions out there that deal with this
I'm trying to select an H1 element which is the second-child in its group

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.