Thread: Jave to C

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    45

    Jave to C

    Hey i am using Dev C++ and a windows computer and i need toconvert the following into a c code -


    var R =6371;// kmvar dLat =(lat2-lat1).toRad();var dLon =(lon2-lon1).toRad();var lat1 = lat1.toRad();var lat2 = lat2.toRad();var a =Math.sin(dLat/2)*Math.sin(dLat/2)+Math.sin(dLon/2)*Math.sin(dLon/2)*Math.cos(lat1)*Math.cos(lat2);var c =2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a));var d = R * c;

  2. #2
    Registered User
    Join Date
    Nov 2011
    Location
    Saratoga, California, USA
    Posts
    334
    code

    math.h

    and write a function to convert degrees to radians?

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Gee - how lazy can you get.

    At least most of the copy/paste crowd at least pretend they're doing something by at least finding code in the right language.
    You couldn't even be bothered to paste it properly - what an eyesore.

    But no, you're special.
    Calculate distance and bearing between two Latitude/Longitude points using Haversine formula in JavaScript
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Apt username.

  5. #5
    Registered User
    Join Date
    Feb 2013
    Posts
    45
    Sorry guys i was just rushed, but i am a beginner to this language.......
    So any ideas how to convert it into c, the fact that i need to write a function to convert degrees to radians doesn't really help

    Cause i have never written a function

    So how do i go about calculating the distance between latitude and longitudinal points ?

  6. #6
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. good book for c++ and jave
    By girijesh.dwived in forum C++ Programming
    Replies: 2
    Last Post: 11-28-2007, 10:38 AM