I am writing a program that calculates the turning forces (moments) on a uniform rod (where the centre of mass is in the middle). I need to split the length of the rod into four values, which themselves don't have to be equal; however, the sum of the first two values must equal the sum of the last two values. The total length of the rod must be randomly generated - so how do I do this?
Here is how I am randomly generating the numbers:
random_value_one = random.uniform(1, 5)
random_value_two = random.uniform(1, 5)
random_value_three = random.uniform(1, 5)
random_value_four = random.uniform(1, 5)
total_length_of_rod = random_value_one + random_value_two + random_value_three + random_value_four
centre_of_mass = total_length_of_rod / 2
Any advice would be greatly appreciated - thanks!
Aucun commentaire:
Enregistrer un commentaire