[fix] clitools tunnel generator should use circles

This commit is contained in:
alban 2020-10-13 22:02:48 +02:00
parent 8e9cd509ab
commit 1e43a5fc43

View File

@ -12,7 +12,7 @@ Use it to test your filters and outputs
LICENCE : CC
by cocoa
by cocoa
'''
@ -52,7 +52,7 @@ randomize = args.randomize
speed = args.speed
verbose = args.verbose
origSpeed = speed
origSpeed = speed
optimal_looptime = 1 / fps
square = [
[-1,1],
@ -62,14 +62,32 @@ square = [
[-1,1]
]
shape = square
circle = [[1,0],
[0.9238795325112867,0.3826834323650898],
[0.7071067811865476,0.7071067811865475],
[0.38268343236508984,0.9238795325112867],
[0,1.0],
[-0.3826834323650897,0.9238795325112867],
[-0.7071067811865475,0.7071067811865476],
[-0.9238795325112867,0.3826834323650899],
[-1.0,0],
[-0.9238795325112868,-0.38268343236508967],
[-0.7071067811865477,-0.7071067811865475],
[-0.38268343236509034,-0.9238795325112865],
[0,-1.0],
[0.38268343236509,-0.9238795325112866],
[0.707106781186548,-0.707106781186547],
[0.9238795325112872,-0.3826834323650887],
[1,0]]
shape = circle
currentCenter = [centerX, centerY]
centerVector= [0,0]
# tweak random basis
if randomize % 2 == 1:
randomize += 1
debug(name,"randomize:{}".format(randomize))
centerRand = int(math.sqrt(randomize) / 4 ) + 1
centerRand = int(math.sqrt(randomize) / 4 ) + 1
debug( name, "centerRand:{}".format(centerRand ) )
class polylineGenerator( object ):
@ -103,10 +121,10 @@ class polylineGenerator( object ):
min_size = 9999
delList = []
if randomize :
# Change the vector
# Change the vector
centerVector[0] += random.randrange( -centerRand,centerRand )
centerVector[1] += random.randrange( -centerRand,centerRand )
# Modify the vector if it is over the limit
# Modify the vector if it is over the limit
if currentCenter[0] + centerVector[0] >= centerX + randomize or currentCenter[0] + centerVector[0] <= centerX - randomize:
centerVector[0] = 0
if currentCenter[1] + centerVector[1] >= centerY + randomize or currentCenter[1] +centerVector[1] <= centerY - randomize:
@ -115,19 +133,19 @@ class polylineGenerator( object ):
currentCenter[1] += centerVector[1]
# Change speed
speed += int( random.randrange( int(-origSpeed),origSpeed ) )
if speed < origSpeed :
if speed < origSpeed :
speed = origSpeed
elif speed > (origSpeed + randomize / 2) :
speed = origSpeed + randomize / 2
speed = origSpeed + randomize / 2
#debug(name, "currentCenter:{} speed:{}".format(currentCenter,speed))
for i, shapeInfo in enumerate(self.polylineList):
size = shapeInfo[0]
# Augment speed with size
# Augment speed with size
"""
size = 0 : += sqrt(speed)
size = half max size : +=speed
"""
if size < max_size / 4:
size += math.pow(speed, 0.1)
@ -143,7 +161,7 @@ class polylineGenerator( object ):
for i in delList:
del self.polylineList[i]
#debug(name, "polyline:",self.polylineList)
if min_size >= interval:
if min_size >= interval:
debug(name, "new shape")
self.polylineList.append([0,[currentCenter[0],currentCenter[1]]])
@ -172,5 +190,5 @@ while True:
if( looptime < optimal_looptime ):
time.sleep( optimal_looptime - looptime)
#debug(name+" micro sleep:"+str( optimal_looptime - looptime))