-1
Hello I am very confused now I took the formula to take the distance between 2 points and applied in my application but this giving result different from the calculator
text code:
public static double GetDist(Point A, Point B)
{
double X, Y;
X = (B.X - A.X) ^ 2;
Y = (B.Y - A.Y) ^ 2;
Debug.WriteLine($"X:{A.X},Y:{A.Y}");
Debug.WriteLine($"X:{B.X},Y:{B.Y}");
Debug.WriteLine($"Result:{X+Y}");
return Math.Sqrt(X+Y);
}
Input: A = {126, 101}, B = {150, 60}.
Code Debug Result from: -17
and in the field of 2257 in Account: (150-126) 2 + (60-101) 2
.
.
Please Ignore the Math. Sqrt please.
I’m sorry if it’s a silly mistake but I make it like seven hours in this mistake.
– Zehous
Try using Math.Pow((B.X - A.X), 2) for x and y values.
– Bernardo Lopes
In C# the operator
^
is not potentiation, is logical connective to the or exclusive bit by bit– Augusto Vasques
Bernardo Lopes and Augusto Vasquel Thanks. One Completed the other in the explanation.
– Zehous
Use Math.Pow(base, exponent) or simply: deltax*deltax
– user178974