Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Define the masses and positions
- mass1 = 5 # Mass in kilograms
- mass2 = 4
- mass3 = 3
- position1 = (0, 0) # Position in meters (x, y)
- position2 = (1, 2)
- position3 = (2, 0)
- # Calculate the center of mass (Xcm, Ycm)
- total_mass = mass1 + mass2 + mass3
- Xcm = (mass1 * position1[0] + mass2 * position2[0] + mass3 * position3[0]) / total_mass
- Xcm = round(Xcm, 2)
- Ycm = (mass1 * position1[1] + mass2 * position2[1] + mass3 * position3[1]) / total_mass
- Ycm = round(Ycm, 2)
- # Print the results
- print(f"Center of Mass: ({Xcm}, {Ycm})")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement