Due to a pro-seminar i had to write last semester, i questioned myself how to calculate the center of mass of a 2D shape. In the papers i read about the topic everywhere it was considered “simple”, but was never discussed. Back then i just accepted this, but recently i thought about the same question again and started tinkering, resulting in this project.
For the definition of the shape, i settled on a black/white picture. The tool is written in Java and is launched via a console. Two modes are provied:
- Open a window, display the image and a red dot at the center of mass
- Silently calculate the point and print it back to the console
As image formats JPG, GIF, PNG and BMP are supported.
javac CenterOfMass.java java CenterOfMass test.png -s