Solved

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

Posted on 2006-04-24
361 Views
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)

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
Question by:verintsupport

LVL 10

Accepted Solution

PointF p1 = new PointF(73.11, 40.2332);

Regards
Prakash
0

LVL 48

Expert Comment

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

is there any point structure in 3d?

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

Richard
0

LVL 48

Expert Comment

Oops, ignore my post.
0

LVL 85

Assisted Solution

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.