<PapeCoding/>

CenterOfMass



CenterOfMass Example launch with image of eifel-tower

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:

  1. Open a window, display the image and a red dot at the center of mass
  2. Silently calculate the point and print it back to the console

As image formats JPG, GIF, PNG and BMP are supported.

1
2
javac CenterOfMass.java
java CenterOfMass test.png -s

CenterOfMass.zip (3.9 KB)