averaging pixel locations to find a surface normal. (2D)

I Am working on a 2D game in XNA that needs some physics. I have found that physics engines such as Farseer will not cut it due to some of the ways they work. (thats a long story involving rewriting the code 3 times to finally figure out that I needed to write the physics myself.) So according to the reference material I'm using, the only data that I need now is a normal for the surface of collision.

This is using per-pixel collision detection using sprites. I currently have an array of all the overlapping pixels and their locations. I would like to use that data to some how average the locations of the overlapping pixels to figure out the normal for that surface. this should then allow me to have collisions with objects of irregular shape but still retain realistic physics interaction.

If anyone has a suggestion on how I could use this pixel info to figure out the surface normal or something close enough, that would be great.



Considered storing normals for each point in your sprites (i.e. in separate texture) instead trying to compute them. This way you'll be able to adjust normals so your collisions look "natural" (in a sense of your game, not necessary correct from physics point of view).

Need Your Help

Cmake: libpng not dynamically linking correctly on a different machine

unix linker dependencies cmake libpng

On Ubuntu 13.04 VM, which was used to build the sc utility, the dependency looks like the below:

Using DataTables.js with editor extension and ASP.NET MVC backend

asp.net-mvc-4 jquery-datatables-editor

I am using datatables with the editor extension to post data to an ASP.NET MVC backend. The action I am calling expects a complex object which I would like it to be able to automatically find the

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.