I have this code ,I want to send pt1 and pt2 when click on button to method I have problem in prototype of pt1 and pt2 what is the change I should to do ?
public double angleOf(Point p1, Point p2)
{
double deltaY = (p2.Y - p1.Y);
double deltaX = (p2.X - p1.X);
double result = Math.Atan2(deltaY, deltaX);
result *= (180 / Math.PI);
result += 22.5;
return (result < 0) ? (360d + result) : result;
}
private void button1_Click(object sender, EventArgs e)
{
double angle;
Point pt1 = 4428900.38515348;
Point pt2 = 4428900.38515346;
angle = angleOf(pt1, pt2);
textBox1.Text += angle;

Suresh MRank #171 · 14K reputationPosted Feb 11, 2016, 11:52 PM EST
meena moon42 reputationPosted Feb 12, 2016, 7:33 AM EST
Shweta LodhaRank #31 · 39.8K reputationPosted Feb 12, 2016, 7:41 AM EST
meena moon,
meena moon42 reputationPosted Feb 12, 2016, 8:11 AM EST
ali tuncerRank #1,499 · 1.1K reputationPosted Feb 13, 2016, 9:37 PM EST
Point pt1 = 4428900.38515348; // this line of code will not build successfully
meena moon42 reputationPosted Feb 14, 2016, 7:05 AM EST
ali tuncerRank #1,499 · 1.1K reputationPosted Feb 14, 2016, 3:14 PM EST
angleOf method takes Point as a parameter.
angle = angleOf(xy.X, xy.Y) // in this line you are sending int, that's what the error message says.
meena moon42 reputationPosted Feb 17, 2016, 11:45 AM EST
ali tuncerRank #1,499 · 1.1K reputationPosted Feb 17, 2016, 3:22 PM EST
I am not sure what you are trying to do, but if you need to use angleOf method, you need to create 2 points, such as :
Point pt2 = new Point(200, 200);
angle = angleOf(pt1, pt2);
textBox1.Text += angle;
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts