Skip to content

eliseuegewarth/3d_center_of_mass

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

3d Center Of Mass

Calculate the Center of mass of all objects in 3d matrix.

Problem

Center of mass (C.O.M.) is a very important information when you need to calculate the trajectory of a body receiving a force. How can we calculate a C.O.M. of any 3D projection? How much computing is necessary?

Solution strategy

The problem can be done by follow this steps:

  • Model the pixels as nodes of the graph
  • Model the neighboring pixels with the same characteristic (Ex: density) as edges
  • Use Graph.BFS to find the components (objects) of the graph
  • Use the strategy of, divide to conquer, to divide the three-dimensional object into lines (make recursively until a 1x1xN matrix remains)
  • Calculate C.O.M. of any line found in the previous step
  • Calculate C.O.M. of any C.O.M. found in the previous step (repeat until close all recursions)

Requirements

This project only need python3 to run. If new libs came to be used, they will be stored in requirements.txt file.

Dev Requirements

Dev requirements are stored on dev-requirements.txt file. Use pip install -r dev-requirements.txt if you are using pip or a equivalent command in your package manager.

Dev Environment

You can easy config a virtualenv by running config_virtualenv.sh. Need virtualenv and virtualenvwrapper installed.