Question

I am computing inward-pointing normals, (dy,-dx) of a list of points. However I think I am not getting correct result, is there a way to verify correctness? I am using:

List<Point> points = new List<Point>(7);
points.Clear();
points.Add(new Point(378, 110));
points.Add(new Point(190, 130));
points.Add(new Point( 65, 365));
points.Add(new Point(300, 100));
points.Add(new Point(500, 425));
points.Add(new Point(225, 395));
points.Add(new Point(378, 110));
int[] dx = new int[7];
int[] dy = new int[7];

// loop over line segments of hull to find inward-pointing normals, (dy,-dx)
for (int j = 0; j < 7- 1; j++)
{   
     dx[j] = P[j + 1].X  - P[j].X;
     dy[j] = P[j + 1].Y  - P[j].Y;
}

dx[7-1] = P[1].X - P[7-1].X;
dy[7-1] = P[1].Y - P[7-1].Y;

However I think I am not getting correct results. I get:

dx          
[0] 125
[1] 110
[2] 78
[3] 122
[4] -275
[5] -160
[6] 125 

dy
[0] -235
[1] -30
[2] 10
[3] 315
[4] -30
[5] -30
[6] -235

Has anyone have experience to compute inward-pointing normals of a list of points?

Was it helpful?

Solution

Take a look at this site to help you with your problem...

https://gamedev.stackexchange.com/questions/26951/calculating-the-2d-edge-normals-of-a-triangle

But basic algebra on a plane notes that inverse normal (N) is equal to -N.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top