Click here to Skip to main content
15,906,569 members
Home / Discussions / C#
   

C#

 
QuestionWindows Forms GUI Library WITHOUT Theming/Skinning? Pin
Uwe Keim12-Jan-09 19:09
sitebuilderUwe Keim12-Jan-09 19:09 
Questionscope operator Pin
lawrenceinba12-Jan-09 18:35
lawrenceinba12-Jan-09 18:35 
AnswerRe: scope operator Pin
dan!sh 12-Jan-09 18:51
professional dan!sh 12-Jan-09 18:51 
QuestionHow to Invoke Upgrade Method of Win32_Product. Pin
banker_kiran12-Jan-09 18:27
banker_kiran12-Jan-09 18:27 
QuestionRemoting - constructor Pin
devvvy12-Jan-09 16:27
devvvy12-Jan-09 16:27 
QuestionC# problem in playing swf file in windows application Pin
leoiser12-Jan-09 16:09
leoiser12-Jan-09 16:09 
AnswerRe: C# problem in playing swf file in windows application Pin
Dragonfly_Lee12-Jan-09 17:59
Dragonfly_Lee12-Jan-09 17:59 
QuestionBeaten and defeated by this simple geography compass problem. Pin
Garry Freemyer12-Jan-09 15:38
Garry Freemyer12-Jan-09 15:38 
HELP!! I am not the type to give up but I am way past wits end! This is for work ....

The goal was simple...

Given the starting and ending latitude and longitude calculate the direction in compass degrees of travel as the crow flies to get to the destination location.

For example if I wanted to travel from say Sacramento to San Diego CA, I might have to travel I want to know how many degrees and what heading to get to Denver.

But ... Every time I search for a solution, the answer evades me and my hopes are crushed as I run into a combination of the following problems over and over again.

1. The site launches into a diatribe dozens of pages long written by some author who seems to delight in hearing or reading his incomprehensible diatribe till my eyes glaze over and I am over-whelmed.

2. The site starts to answer the question but then half way through it changes direction and ends up answering an entirely different question. Example: Half way through they stop and answer a different question like finding the distance of travel between the two points or the longitude and latitude of the mid-point and then just stops right there and never gets to answering the problem.

3. The week before last this start out saying they will show the formula for this and stating the question completely but when they get to the formula and example page, their page is missing the controls for entering the destination latitude, and also the formula they use leave this out too, and of course the answer is not forthcoming.

So finally last Friday I find a site that says if you want the formula for calculating this than look no further and they give me the code.

Here it is below and it works between say Paradise CA, and Denver Colorado, and the other way around but when I asked what was the direction from Paradise, CA, to San Diego CA, instead of say 220 Degrees (SW Generally), it comes out and says it's 44 Degrees.

I am not the type to quit, which was what some friends said when I mention that I have failed and am defeated, I can't solve this and I've spent many times over the amount of time it should have taken to solve this but I am defeated completely.

here's the code. Here's your chance any smart folks out there to solve this, but for me I am the retard, and I can't figure it out and I give up. Hopefully someone is up to the challenge. It's over for me. I will have to hunker down to pencil and paper and make some rube-goldberg piece of code because I cannot find an elegant solution out there and I am beyond pissed about it.

Here is the defines for it ....

#define MILES 3963.1
#define NauticalMiles 3443.9
#define KILOMETERS 6378

#define ParadiseLat 39.743
#define ParadiseLon -121.605

#define SanDiegoLat 32.723
#define SanDiegoLon -117.165

#define ColoSpringsLat 38.835
#define ColoSpringsLon -104.823

#define PI 3.14159265358979323846

Here is the function the main function below calls...


double degreesToRadian(double x)
{
return (M_PI * (x) / 180.);
}

Here is the main function below, it works for say Colorado Springs to Paradise CA and vice versa but falls flat on Paradise CA, to San Diego. It returns a rediculous answer of 44 degrees. Good luck, if you can find a solution you are far smarter than I am which right now doesn't sound like much of a challenge.

double latitudeLongitudeLocationsToAngleOfTravelInDegrees(double latRad1, double lonRad1, double latRad2, double lonRad2)

{

double theRadians = atan2(cos(latRad1)*sin(latRad2)-sin(latRad1)*cos(latRad2)*cos(lonRad2-lonRad1), sin(lonRad2-lonRad1)*cos(latRad2));

double theDegreesInRad = radianToDegrees(theRadians);

theDegreesInRad = (theDegreesInRad * PI / 180) + 360;

int theDegrees = radianToDegrees(theDegreesInRad);

theDegrees = theDegrees % 360;

return theDegrees;

}

Been there, done that, forgot why!

AnswerRe: Beaten and defeated by this simple geography compass problem. [modified] Pin
Luc Pattyn12-Jan-09 16:08
sitebuilderLuc Pattyn12-Jan-09 16:08 
GeneralRe: Beaten and defeated by this simple geography compass problem. Pin
PIEBALDconsult12-Jan-09 16:15
mvePIEBALDconsult12-Jan-09 16:15 
AnswerRe: Beaten and defeated by this simple geography compass problem. Pin
Luc Pattyn12-Jan-09 16:25
sitebuilderLuc Pattyn12-Jan-09 16:25 
GeneralRe: Beaten and defeated by this simple geography compass problem. Pin
PIEBALDconsult12-Jan-09 19:47
mvePIEBALDconsult12-Jan-09 19:47 
AnswerRe: Beaten and defeated by this simple geography compass problem. Pin
Luc Pattyn13-Jan-09 2:27
sitebuilderLuc Pattyn13-Jan-09 2:27 
GeneralRe: Beaten and defeated by this simple geography compass problem. Pin
Garry Freemyer12-Jan-09 16:16
Garry Freemyer12-Jan-09 16:16 
AnswerRe: Beaten and defeated by this simple geography compass problem. [modified] Pin
Luc Pattyn12-Jan-09 16:32
sitebuilderLuc Pattyn12-Jan-09 16:32 
GeneralI keep getting zero as the angle no matter what. [modified] Pin
Garry Freemyer13-Jan-09 6:04
Garry Freemyer13-Jan-09 6:04 
AnswerRe: I keep getting zero as the angle no matter what. [modified] Pin
Luc Pattyn13-Jan-09 6:37
sitebuilderLuc Pattyn13-Jan-09 6:37 
GeneralRe: I keep getting zero as the angle no matter what. Pin
Garry Freemyer13-Jan-09 7:12
Garry Freemyer13-Jan-09 7:12 
AnswerRe: I keep getting zero as the angle no matter what. [modified] Pin
Luc Pattyn13-Jan-09 8:14
sitebuilderLuc Pattyn13-Jan-09 8:14 
GeneralRe: I keep getting zero as the angle no matter what. Pin
Garry Freemyer13-Jan-09 14:04
Garry Freemyer13-Jan-09 14:04 
GeneralRe: I keep getting zero as the angle no matter what. Pin
Garry Freemyer13-Jan-09 14:06
Garry Freemyer13-Jan-09 14:06 
AnswerRe: Beaten and defeated by this simple geography compass problem. Pin
PIEBALDconsult12-Jan-09 16:12
mvePIEBALDconsult12-Jan-09 16:12 
GeneralRe: Beaten and defeated by this simple geography compass problem. Pin
Garry Freemyer12-Jan-09 16:22
Garry Freemyer12-Jan-09 16:22 
GeneralRe: Beaten and defeated by this simple geography compass problem. Pin
Jason Lepack (LeppyR64)12-Jan-09 16:47
Jason Lepack (LeppyR64)12-Jan-09 16:47 
GeneralRe: Beaten and defeated by this simple geography compass problem. Pin
PIEBALDconsult12-Jan-09 19:49
mvePIEBALDconsult12-Jan-09 19:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.