I'm going to define some terms so it's easier to understand what I'm talking about.
- Stream: a curve or a line or a polyline of multiple circles
- Curve intensity: a value in [0 ; 2] which will be used to call circle_space (ex:
circle_space[curve_intensity[c]]
) (we will see what circle_space is later)
What I'm trying to make is a stream which contain accelerations and deceleration. to make this possible, I need to either gradually increase or decrease the space between 2 circles. for this I need the speed associated with the curve composing the polyline. let's say circle_space = [20,25,30]
meaning the index 0 is the minimum speed, index 2 is the maximum.
Now let's say the first curve is decelerating (by either 1 or 2), it need to gradually go from a speed to another right? And speed is defined by spacing.
here is the distance formula I'm using right now user_dist = circle_space[curve_intensity[c]] + curve_acceleration[c] * p
where c is the index of one of the actual curves I'm looping through and p is the point contained in the active curve that's I'm looping through. curve in the next example is the polyline (fusion of curves and lines) curve = [curve_0, curve_1, curve_2] and curve_0 = [[0,0], [1,0], [1,1]] same format for other curves but with different coordinates.
the issue is that right now, this isn't working, causing things such as this
in this situation, curve_intensity = [2, 0, 0, 0, 1, 0]
and curve_acceleration = [-0.030000000000000002, 0.0, 0.015000000000000001, -0.015000000000000001]
so we can see that the first stream (between 0 and 2 on the first image) is decelerating, but we can also see that the spacing isn't equal to the minimum defined, same goes for accelerating streams. (it should gradually go from a spacing to another) how can I fix this spacing issue?
this is the code that place the circles depending on circle_space:
def Place_circles(curve, circle_space, cs, resolution, draw=True, screen=None):
curve_acceleration = []
if type(curve) == tuple:
curve_acceleration = curve[1][0]
curve_intensity = curve[1][1]
curve = curve[0]
print(curve_intensity)
print(curve_acceleration)
Circle_list = []
idx = [0,0]
for c in reversed(range(0,len(curve))):
for p in reversed(range(0,len(curve[c]))):
if not curve_acceleration and type(circle_space) == int:
user_dist = circle_space
dist = math.sqrt(math.pow(curve[c][p][0] - curve[idx[0]][idx[1]][0],2)+math.pow(curve [c][p][1] - curve[idx[0]][idx[1]][1],2))
if dist > user_dist:
idx = [c,p]
Circle_list.append(circles.circles(round(curve[c][p][0]), round(curve[c][p][1]), cs, resolution, draw, screen))
else:
user_dist = circle_space[curve_intensity[c]] + curve_acceleration[c] * p
dist = math.sqrt(math.pow(curve[c][p][0] - curve[idx[0]][idx[1]][0],2)+math.pow(curve [c][p][1] - curve[idx[0]][idx[1]][1],2))
if dist > user_dist:
idx = [c,p]
Circle_list.append(circles.circles(round(curve[c][p][0]), round(curve[c][p][1]), cs, resolution, draw, screen))
code of my generator including this acceleration feature: https://github.com/Mrcubix/Osu-StreamGenerator/tree/acceleration
Aucun commentaire:
Enregistrer un commentaire