Cags
Contributor
I'm trying to work out the distance between 2 points which is obviously done by doing X1 - X2. As the points can be either way around and I need a positive number i'm currently using an if statement to find out which is biggest. Then taking the smallest from the largest. Is there an easier way of ensuring the number is positive. Mathematically speaking I could just square then square root the number, but this doesn't seem any more elegant than an if statement.
My current code...
My current code...
C#:
if(e.X > pSelStart.X)
iWidth = e.X - pSelStart.X;
else
iWidth = pSelStart.X - e.X;