i want to convert graphical x,y coordinates x,y to mathematical coordinated
( in this picture you see the Differences between graphical x,y and mathematical x,y
the graphical x and graphical y obtain by e event
int graphicalx;
int graphicaly;
graphicalx = e.X;
graphicaly = e.Y;
and they showed by two label in the form just should move the mouse on the form
Now the formula for convert graphicalx,y to mathematical x,y is this :
Graphical x = mathematical x + Alfa
Graphical y = - mathematical y + Beta
Now the Alfa and Beta obtain by this :
you get the your computer resolution :
for sample mine is : 1600 * 800
alfa = 1600 /2 = 800
beta = 800/2 = 450
At last :
alfa = 800
beta = 450
and now my program don`t works well , where is the problem?
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
int graphicalx;
int graphicaly;
int mathematicalx;
int mathematicaly;
graphicalx = e.X;
graphicaly = e.Y;
if (graphicalx > 0)
{
graphicalx = graphicalx * -1; //if graphicalX was positive do it negative
}
if (graphicaly > 0)
{
graphicaly = graphicaly * -1; //if it graphicalY was positive do it negative
}
if (graphicalx < 0)
{
graphicalx = graphicalx * +1; // if graphicalX was negative do it positive
}
if (graphicaly < 0)
{
graphicaly = graphicaly * +1; // if graphicalY was negative do it positive
}
mathematicalx = graphicalx + 800; // the formula for obtain the mathematical x
mathematicaly = graphicaly * -1 + 450; // the formula for obtain the mathematical y
label1.Text = "X = " +mathematicalx.ToString();
label3.Text = "Y = " + mathematicaly.ToString();
}
Form 1 Properties :
Windows state = Maximized
FormBorderStyle = None