?
Solved

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

Posted on 2006-04-24
5
Medium Priority
?
367 Views
Last Modified: 2008-03-03
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;

0
Comment
Question by:verintsupport
5 Comments
 
LVL 10

Accepted Solution

by:
prakash_prk earned 1000 total points
ID: 16531937
please try the PointF structure

PointF p1 = new PointF(73.11, 40.2332);

Regards
Prakash
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 16531986
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
 

Author Comment

by:verintsupport
ID: 16531990
is there any point structure in 3d?

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

Richard
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 16531991
Oops, ignore my post.
0
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 1000 total points
ID: 16534746
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month14 days, 23 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question