Cocoa 48Hour Programming Challenge
I'll like to see how many of you are savvy with Cocoa. So here is a challenge for you to be completed in 48hours.
* Place the link for your app
* We vote for the best
* You show your source code
* No prizes, just glory
* Only ObjectiveC entries
* The time is based on the time of this post.
Challenge: Calculate the Distance Using Latitude and Longitude between two locations.
Anything extra will help your chances, and should give you extra "ohhs and ahhhs" (ie, showing 3d vectors to show the distance, a 3d globe, entering of city names, etc)
Here is the info you need:
Good Luck,
* Place the link for your app
* We vote for the best
* You show your source code
* No prizes, just glory
* Only ObjectiveC entries
* The time is based on the time of this post.
Challenge: Calculate the Distance Using Latitude and Longitude between two locations.
Anything extra will help your chances, and should give you extra "ohhs and ahhhs" (ie, showing 3d vectors to show the distance, a 3d globe, entering of city names, etc)
Here is the info you need:
Quote:Calculating Distance Using Latitude and Longitude
In this database, the location of ZIP codes is defined in terms of degrees of
north latitude and degrees of west longitude. Because of the spherical shape
of the Earth, calculating the exact distance between two ZIP codes requires
the use of spherical geometry and trigonometric math functions. However, you can calculate an approximate distance using much simpler math functions. For many applications the approximate distance calculation provides sufficient accuracy with much less complexity.
The following approximate distance calculations are relatively simple, but can
produce distance errors of 10 percent of more. These approximate calculations are performed using latitude and longitude values in degrees, as defined in this database. The first approximation requires only simple math functions:
Approximate distance in miles = sqrt(x * x + y * y)
where x = 69.1 * (zip2.lat  zip1.lat)
and y = 53 * (zip2.lon  zip1.lon)
You can improve the accuracy of this approximate distance calculation by
adding the cosine math function:
Approximate distance in miles = sqrt(x * x + y * y)
where x = 69.1 * (zip2.lat  zip1.lat)
and y = 69.1 * (zip2.lon  zip1.lon) * cos(zip1.lat/57.3)
If you need greater accuracy, you must use the exact distance calculation. The
exact distance calculation requires use of spherical geometry, since the Earth
is a sphere. The exact distance calculation also requires a high level of
floating point mathematical accuracy  about 15 digits of accuracy (sometimes called "doubleprecision"). Many computer languages do not provide sufficient accuracy for this calculation. In addition, the trig math functions used in the exact calculation require conversion of the latitude and longitude values from degrees to radians. To convert latitude or longitude from degrees to radians, divide the latitude and longitude values in this database by 180/pi, or 57.2958. The radius of the Earth is assumed to be 6,371 kilometers, or 3,958.75 miles.
If you convert all latitude and longitude values in the database to radians
before the calulation, use this equation:
Exact distance in miles = 3958.75 * arccos[sin(zip1.lat) *
sin(zip2.lat) + cos(zip1.lat) *
cos(zip2.lat) * cos(zip2.lon  zip1.lon)]
If you do NOT first convert the latitude and longitude values in the database
to radians, you must include the degreestoradians conversion in the
calculation. Substituting degrees for radians, the calculation becomes:
Exact distance in miles = 3958.75 * arccos[sin(zip1.lat/57.2958) *
sin(zip2.lat/57.2958) +
cos(zip1.lat/57.2958) *
cos(zip2.lat/57.2958) *
cos(zip2.lon/57.2958  zip1.lon/57.2958)]
If the computer language you are using has no arccosine function, you can
calculate the same result using the arctangent function, which most computer
languages do support. Use the following equation:
Exact distance in miles = 3958.75 * arctan[sqrt(1x^2))/x]
where x = [sin(zip1.lat/57.2958) * sin(zip2.lat/57.2958)] +
[cos(zip1.lat/57.2958) *
cos(zip2.lat/57.2958) *
cos(zip2.lon/57.2958  zip1.lon/57.2958)]
Using the latitude and longitude values provided by this database, you should
be able to obtain distance accuracy of approximately +/ 36 feet.
If your distance calculations produce wildly incorrect results, check for
these possible problems:
1. Did you convert the latitude and longitude values from degrees to
radians? Trigonometric math functions such as sine and cosine normally
require conversion of degrees to radians, as described above.
2. Are the equations implemented correctly with necessary parentheses?
Remember the old math precedence rule: MDAS  multiply, divide, add,
subtract.
3. Does your computer language provide sufficient mathematical accuracy?
Many languages simply do not provide the required floating point
precision. For best results, you need about 15 digits of accuracy.
Older versions of Basic, for example, often provide much less accuracy
than required for the exact distance calculation.
4. Did you retain decimal points in the latitude and longitude values?
When you imported the data into your database program, you may have
lost the decimal point during the importation of latitude and longitude
values.
Good Luck,
Carlos A. Camacho,
Founder
iDevGames
eww, miles.
*looks for barfing face smiley*
*looks for barfing face smiley*
Damn you with your challenges.
I'm gonna ruin my session 'cause of this... But.. I.. can't... resist...
 Sohta
Er...not much warning, eh? Another "Ijustsprungitonyou" contest?
My web site  Games, music, Python stuff
Think of it like a popquiz.
OSC... extra ohhs for people who know kilometers and miles.
OSC... extra ohhs for people who know kilometers and miles.
Carlos A. Camacho,
Founder
iDevGames
Carlos, next time you should give them 48 hours to write a program that, given a bunch of wishlists of winning developers, will calculate who gets what. And then contacts each of the sponsors automatically. :)
Measure twice, cut once, curse three or four times.
Being professional about this, I thought I had better check the specs of this project before commencing it.
The app you are after takes 2 points as input and returns the distance between the two.
The talk of databases is not relevant, just it happens to be in the reference document you provided?
(Now I just wonder if this is going to be so realistic that the client does not respond until the deadline is 1 hour away )
The app you are after takes 2 points as input and returns the distance between the two.
The talk of databases is not relevant, just it happens to be in the reference document you provided?
(Now I just wonder if this is going to be so realistic that the client does not respond until the deadline is 1 hour away )
No can do this time. But... I love things like this. I think these are exactly the sorts of things we need to see more often here. Do it more!
geezusfreeek Wrote:No can do this time. But... I love things like this. I think these are exactly the sorts of things we need to see more often here. Do it more!How about: winner of this challenge gets to help pick the next 48hour challenge?
(Caveats: Carlos gets final say over the appropriateness of the challenge. And people who set the challenge have to sit it out.)
Measure twice, cut once, curse three or four times.
How about each time somebody wins one he is handicapped a couple of hours for later ones (he has to send it in sooner)? Keep the competition going a little more? Let people other than the superelite have a chance?
BeyondCloister Wrote:The app you are after takes 2 points as input and returns the distance between the two.
The talk of databases is not relevant, just it happens to be in the reference document you provided?
Everything seems to imply that the program will just take coordinates and return a distance. Carlos doesn't provide you with zip codes and corresponding coordinates so I don't think he expects you to use a database, and that it is indeed just part of the reference document. But listening to me would be taking advice from someone who knows no more than you do, so you can still cross your fingers and hope Carlos replies before the deadline
Of course if you do build in database support I'm sure you'd get all kinds of 'leet props Or something
Use what you can, or what you want. I'm very flexible. As for voting, place your link to download and after we all try them, we can all vote on them.
I admit that this idea came to me in about 30 seconds. I was searching for GIS data for Mexico, since I have to make various GIS maps of Mexico for my company's next project. And so I came across this, and thought, "that would make for an interesting programming challenge."
I'm keen to run more of them in the future, and will think them through in advance much more. Having people suggest the next contest is good. I have a long list of stuff that I would like to see worked on. Little stuff that can perhaps be useful to learn from, for game programming.
Anyhow, good luck. If you have a question on something that is not clear, like the database, simply state what you think, and if everyone agrees, then we make it "so."
Cheers,
I admit that this idea came to me in about 30 seconds. I was searching for GIS data for Mexico, since I have to make various GIS maps of Mexico for my company's next project. And so I came across this, and thought, "that would make for an interesting programming challenge."
I'm keen to run more of them in the future, and will think them through in advance much more. Having people suggest the next contest is good. I have a long list of stuff that I would like to see worked on. Little stuff that can perhaps be useful to learn from, for game programming.
Anyhow, good luck. If you have a question on something that is not clear, like the database, simply state what you think, and if everyone agrees, then we make it "so."
Cheers,
Carlos A. Camacho,
Founder
iDevGames
I was just thinking  wouldn't it be cool to use such a little app, anjd then enter everyone's lat/long. and then we all can see who is nearest to us, and who is furthest from us. Would be useful if anyone here plans to go around the world and stay at the home of a forum member.
Carlos A. Camacho,
Founder
iDevGames
10 bucks says Carlos needed an application to do this.
Possibly Related Threads...
Thread:  Author  Replies:  Views:  Last Post  
GamePress Greatest Game Challenge  VPrime  1  1,490 
Oct 28, 2013 06:15 PM Last Post: VPrime 

Moscrif game development challenge  Turok  0  2,805 
Oct 1, 2012 08:38 AM Last Post: Turok 

Zerohour game jam  JustinFic  7  7,341 
Nov 9, 2011 12:04 AM Last Post: funkboy 

Google AI Challenge  OneSadCookie  13  12,533 
Dec 2, 2010 06:42 PM Last Post: PowerMacX 

Announcing the Macworld 2010 GameSalad Challenge!  GameSalad  3  6,554 
Dec 30, 2009 06:23 PM Last Post: pinguoren 