15,966,543 members
See more:
Hi.How do I find angle between two pixcels...
Posted
austinbox 29-Jan-14 11:29am
Well if you want the angle between the two pixels you can use Math.atan2.
For example:

double angleInDegrees = Math.Atan2(pix2.y - pix1.y, pix2.x - pix1.x) * (180 / Math.PI);
Can you be more specific? Pixel as most people understand it is a dot/point. I dont see what could be an angle in this case. How do you define an angel beteen two pixels?

## Solution 3

There is a lot of resources about that online.

## Solution 2

That makes no sense : there is no angle between two pixels.
You need at least 3 pixels, which could define two segments; you can then measure an angle between these segments.

OriginalGriff 29-Jan-14 11:35am
Think in terms of two pixels on a bitmap: they both have an X and Y coordinate, so they have a relative angle within the framework:
If one is (0,0) and the other is (100,100) then the angle is at 45 degrees to the baseline X and Y axes.
phil.o 29-Jan-14 11:45am
Maybe I remind too much about my mathematics courses :)
Or maybe I just do not like making assumptions about OP's needs. Here the 45° example is working; but what about (0,0) and (87,134)? Does he want the angle with X or Y axis? As they clearly cannot equal each other.

## Solution 1

Try:
C#
```Point p1 = new Point(100, 100);
Point p2 = new Point(150, 50);
double radians = Math.Atan2(p2.Y - p1.Y, p2.X - p1.X);
```

Rahul VB 29-Jan-14 12:27pm
that great OG, how have you been?
OriginalGriff 29-Jan-14 13:55pm
Not too bad - a little disappointed with tonights food, but...it was a new recipe, and I won't do it again! I did wonder just how risotto was going to work in the Sous Vide and now I know. Not so much "risotto" as "chicken, mushroom and rice soup". :sigh:
Yourself?
Rahul VB 29-Jan-14 21:17pm
great i just had some chapattis with Egg curry. Its cold here, dint feel like going out. Other wise i thought of getting some wine too. But never the less, we always have week ends to full fill our dreams. :) hahah