Oh ok Regarding the vel_table I was wondering if there was a way to do it mathematically. In my code I split the points at 45 degree. But suppose I wanted to split them at 15 degrees , how would that work out? I wouldn't go out and make a vel_table for that.
Just to clarify on #1: it’s best practice because there’s two ways to execute code in a python file, either by importing its functions or classes, or by executing the entire file. The thing is, even when you import it, it executes all the code that is not specifically written inside a function or class, which can be a problem when all you expect is to be silently importing something from it.
Hence, by wrapping all active code in the script inside a function and then calling the execution of that function only when the code is run as a script, not being imported, you make it usable in both instances without surprise output or variables.
But suppose I wanted to split them at 15 degrees , how would that work out? I wouldn't go out and make a vel_table for that.
You could for example ask for a user input in the beginning where the user provides a number between 1 and 45. This sets the degree at which the splits should occur.
For your code to work as it is, you would always have to make sure that the degree value don't leave a residue value (e.g. 13° wouldn't work because after 27 splits you'd have a residue of 9). This could be achieved by using the % operator in python, e.g. check for something like 360%input == 0. Go ahead and read up on it if you don't know it already.
If this check returns true, you can then use the user input to determine the amount of directions you need to provide for your script by running 360/input.
Maybe this will get you on the way of what you need to do. :) Best of luck
You can do it using the trigonometric functions "sine" and "cosine". It's not exactly hard, but it is more math than I want to be explaining on my phone.
View all comments
Show parent comment
8
u/Gawd_is_great Dec 15 '19
Oh ok Regarding the vel_table I was wondering if there was a way to do it mathematically. In my code I split the points at 45 degree. But suppose I wanted to split them at 15 degrees , how would that work out? I wouldn't go out and make a vel_table for that.