palms_spaghetti
Account Details
SteamID64 76561198039105173
SteamID3 [U:1:78839445]
SteamID32 STEAM_0:1:39419722
Country United Kingdom
Signed Up June 16, 2017
Last Posted May 3, 2018 at 1:11 PM
Posts 1 (0 per day)
Game Settings
In-game Sensitivity
Windows Sensitivity
Raw Input  
DPI
 
Resolution
 
Refresh Rate
 
Hardware Peripherals
Mouse  
Keyboard  
Mousepad  
Headphones  
Monitor  
#16 anyone decent with python? in Off Topic

I'd start by doing it for 2 vectors only, where you would set 4 variables at the start of the program to whatever the user inputs, say v1Magnitude and v1Angle for the first vector's inputs, and v2Magnitude and v2Angle for the other vector.

Next make a function that takes the magnitude and angle and returns the x component, and a similar function for the y component, so

v1XComponent = calculateXComponent(v1Magnitude, v1Angle)
v1YComponent = calculateYComponent(v1Magnitude, v1Angle)
v2XComponent = ...

and then do similar functions for the rest of the steps involved in the calculations. This can all be done sequentially with pretty much no looping required.

Since you are required to use at least one loop, this version of the program won't fill all of the requirements. Storing the magnitudes and angles in a list (for example a list for magnitudes and a list for angles) instead of making a load of variables would allow for some looping to go on, such as

for i in range(0,2)
     xComponentList[i] = calculateXComponent(magnitudeList[i], angleList[i])
     yComponentList[i] = calculateYComponent(magnitudeList[i], angleList[i])

where the indexes of each item in the list tells us the order in which the vectors were input into the program.

This could be much better implemented by using a class for each vector, but since there is no mention of classes in the requirements, using a bunch of lists will probably be good enough for the project. There are some good tutorials of how to create and use classes in Python on codecademy.

posted about 6 years ago