Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy
- import math as m
- #!!! CHANGE THESE !!!----------------------------------------------------------
- AUTHOR = 'SlavaCat'
- NAME = 'MATH LFO >:O'
- X_RANGE = [-5,5] #DISTANCE BETWEEN * RESOLUTION MUST BE <= 100 ALSO NO DECIMALS
- #Number of subdivisions between points | 1 = none
- RESOLUTION = 5
- #How many decimals to round to
- ROUND_RANGE = 3
- def equation(x_pos):
- #!!! ADD VARIABLES HERE X IS DEFAULT !!!
- x = x_pos
- #!!! INSTER EQUATION HERE | ADD 'm.' BEFORE OPPERATION !!!
- y = m.tan(x)
- #!!! OK STOP CHANGING THINGS >:( !!!
- return y
- #------------------------------------------------------------------------------
- VITAL_RANGE = [0,1]
- def scale_toRange(unscaled,range_start,range_end):
- unscaled = numpy.ndarray.tolist(numpy.interp(unscaled, (min(unscaled), max(unscaled)), (range_start,range_end)))
- return unscaled
- def round_list(unrounded,round_amount):
- for x in range(len(unrounded)):
- unrounded[x] = round(unrounded[x],ROUND_RANGE)
- return unrounded
- #Set points
- POINTS = (abs(X_RANGE[0]-X_RANGE[1])*RESOLUTION)
- powers = []
- for n in range(POINTS):
- powers.append(0)
- if POINTS >= 200:
- print("!!!WARNING!!! THIS MANY POINTS COULD CRASH VITAL !!!WARNING!!!\n")
- #Creating the x_values
- x_values = []
- for x in range((X_RANGE[0]*RESOLUTION),(X_RANGE[1]*RESOLUTION)):
- x_values.append(x)
- #Scaling the values back to range
- x_values = scale_toRange(x_values,X_RANGE[0],X_RANGE[1])
- #Creating y_values from equation
- y_values = []
- for x_pos in range(POINTS):
- x = x_values[x_pos]
- y_values.append(equation(x))
- #Scaling x to the Vital range of (0,1)
- x_values = scale_toRange(x_values,VITAL_RANGE[0],VITAL_RANGE[1])
- x_values = round_list(x_values,ROUND_RANGE)
- #Again scaling y to Vital range
- y_values = scale_toRange(y_values,VITAL_RANGE[0],VITAL_RANGE[1])
- y_values = round_list(y_values,ROUND_RANGE)
- #Combine
- LFO_points = []
- for x in range(POINTS):
- LFO_points.extend((x_values[x],y_values[x]))
- paste = '{' + (f'"author":"{AUTHOR}","name":"{NAME}","num_points":{POINTS},"points":{LFO_points},"powers":{powers},"smooth":false') + '}'
- print(paste)
- print('\n')
- if POINTS > 100:
- print('You have too many points, results might not be as expected :/')
- #CREATED BY SLAVACAT: https://soundcloud.com/slavacat
Add Comment
Please, Sign In to add comment