2

any reference site for the format code for tinygps.h to measure distance? or any codes for tinygps.h for measuring distance i'm just a beginner in learning arduino thank you

asked Feb 21, 2020 at 0:14
1
  • 1
    Do you know Pythagoras's theorem? Commented Feb 21, 2020 at 0:22

1 Answer 1

1

You don't use the tinygps.h library to measure distance. You use the tinygps.h library to get coordinates. Over short distances those coordinates (longitude and latitude) can be equated to x,y coordinates on a plane (over greater distance - hundreds or thousands of miles - it gets a whole lot more complex).

Two sets of x,y coordinates form a line. A line is one side of a right-angled triangle (the hypotenuse).

Pythagoras (remember him from math class? That rubbish you thought you'd never need? Well, now you do...) says that the square of the hypotenuse is equal to the sum of the squares of the other two sides.

You know the other two sides - they're just the difference between the two x coordinates and the two y coordinates.

We're not going to write the code for you, and Google is probably better at finding websites with example code on than we are.

answered Feb 21, 2020 at 0:28
1
  • thanks man appreciate it :D by the way can i use this format code? float X = ((long2 - long1) * 24901 * cos(lat1)) / 360.0 float Y = ((lat2 - lat1) * 24860) / 360.0 float X2 = X * X; float Y2 = Y * Y; float Distance = sqrt(X2 + Y2); also how to define to my arduino that i set Lon1 Lat1 is equal to my desired gps coordinates should i used long or const or float sorry for many question Commented Feb 21, 2020 at 0:44

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.