Can i use a system.drawing.point to store 2 doubles?

See code on this link: http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_21494399.html?query=point++with+double&topics=327


Lat longs need doubles.... can i use this code with doubles? It seems point needs int as arguments.

Thanks

Richard

copy of the code:
// Define our two points
Point p1 = new Point(73, 40); // 73 degrees west 40 degrees north (New York City)
Point p2 = new Point(-6, 50); // 6 degrees east and 50 degrees north (Cologne)

double DegToRadFactor = (Math.PI / 180);
double RadiusOfTheEarth = 3959; /// Radius of the earth in miles (can also be 6371 kilometers)

/// Math.Cos just use radiants, instead of degrees, so calculate the rad's
double p1X = p1.X * DegToRadFactor;
double p1Y = p1.Y * DegToRadFactor;
double p2X = p2.X * DegToRadFactor;
double p2Y = p2.Y * DegToRadFactor;
               
double der = Math.Cos(p1Y) * Math.Cos(p2Y) * Math.Cos(p2X - p1X) + Math.Sin(p1Y) * Math.Sin(p2Y);
               
/// Calculate Distance
double distance = Math.Acos(der) * RadiusOfTheEarth;

verintsupportAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

prakash_prkCommented:
please try the PointF structure

PointF p1 = new PointF(73.11, 40.2332);

Regards
Prakash
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AlexFMCommented:
Cast integer to double. I guess p1Y is p1.Y, so you need:

double der = Math.Cos((double)p1.Y) * Math.Cos((double)p2.Y) * Math.Cos((double)p2.X - (double)p1.X) + Math.Sin((double)p1.Y) * Math.Sin((double)p2.Y);
0
verintsupportAuthor Commented:
is there any point structure in 3d?

(x,y,z) all in double?
Thanks

Richard
0
AlexFMCommented:
Oops, ignore my post.
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
You can define your own struct...

        private struct Point3D
        {
            public double x;
            public double y;
            public double z;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Point3D p;
            p.x = 73.11;
            p.y = 40.2332;
            p.z = 115.233;
        }
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.