示例#1
0
def start(str):
    t = 0.0  # time (counter)
    res = 256.0  # resolution of curve
    x_m = 100.0  # amplitude
    t_m = 400.0  # max t value
    beta = 0.04  # attenuation
    m = 1.0  # mass
    w_d = 0.05  # angular frequency without attenuation
    f = 0.0  # function value
    fo = 32000  # old function value
    step = t_m / res

    # x-axis:
    qcad.rsPyAddLine(0, 0, t_m, 0)
    #while t<2*math.pi:
    #	qcad.rsPyAddLine(n, 0, n, -0.05)
    #	t+=math.pi/4

    # y-axis:
    qcad.rsPyAddLine(0, -x_m, 0, x_m)

    # oscillation
    fo = 32000
    t = 0.0
    while t < t_m:
        f = x_m * math.exp((-beta / (2.0 * m)) * t) * math.sin(w_d * t)
        if (fo != 32000):
            qcad.rsPyAddLine(t - step, fo, t, f)
        t += step
        fo = f

    # x_m:
    fo = 32000
    t = 0.0
    while t < t_m:
        f = x_m * math.exp((-beta / (2.0 * m)) * t)
        if (fo != 32000):
            qcad.rsPyAddLine(t - step, fo, t, f)
            qcad.rsPyAddLine(t - step, -fo, t, -f)
        t += step
        fo = f

    return (1)
示例#2
0
def start(str):
	t=0.0      # time (counter)
	res=256.0  # resolution of curve
	x_m=100.0  # amplitude
	t_m=400.0  # max t value
	beta=0.04  # attenuation
	m=1.0      # mass
	w_d=0.05   # angular frequency without attenuation
	f=0.0      # function value
	fo=32000   # old function value
	step=t_m/res
	
	# x-axis:
	qcad.rsPyAddLine(0, 0, t_m, 0)
	#while t<2*math.pi:
	#	qcad.rsPyAddLine(n, 0, n, -0.05)
	#	t+=math.pi/4

	# y-axis:
	qcad.rsPyAddLine(0, -x_m, 0, x_m)

	# oscillation
	fo=32000
	t=0.0
	while t<t_m:
		f = x_m * math.exp((-beta/(2.0*m))*t) * math.sin(w_d * t)
		if (fo!=32000):
			qcad.rsPyAddLine(t-step, fo, t, f)
		t+=step
		fo=f
	
	# x_m:
	fo=32000
	t=0.0
	while t<t_m:
		f = x_m * math.exp((-beta/(2.0*m))*t)
		if (fo!=32000):
			qcad.rsPyAddLine(t-step, fo, t, f)
			qcad.rsPyAddLine(t-step, -fo, t, -f)
		t+=step
		fo=f
		
	return(1)
示例#3
0
def start(str):
    x_m = 100.0  # x amplitude
    y_m = 100.0  # y amplidute
    w_x = 0.9  # x angle frequency
    w_y = 0.7  # y angle frequency
    t = 0.0  # time (counter)
    x = 0.0  # current pos
    y = 0.0
    ox = 32000  # old pos
    oy = 32000
    res = 128  # resolution (number of lines)

    # lissajous
    while t < math.pi * 10:
        x = x_m * math.cos(w_x * t)
        y = y_m * math.cos(w_y * t)
        if ox != 32000:
            qcad.rsPyAddLine(ox, oy, x, y)
        ox = x
        oy = y
        t += 0.1
    return (1)
示例#4
0
文件: lissajous.py 项目: Akaur/qdraw
def start(str):
	x_m = 100.0   # x amplitude
	y_m = 100.0   # y amplidute
	w_x = 0.9     # x angle frequency
	w_y = 0.7     # y angle frequency
	t = 0.0       # time (counter)
	x = 0.0       # current pos
	y = 0.0
	ox = 32000    # old pos
	oy = 32000
	res = 128     # resolution (number of lines)
	
	# lissajous
	while t<math.pi*10:
		x = x_m * math.cos(w_x * t)
		y = y_m * math.cos(w_y * t)
		if ox!=32000:
			qcad.rsPyAddLine(ox, oy, x, y)
		ox = x
		oy = y
		t += 0.1
	return(1)
示例#5
0
文件: sine.py 项目: Akaur/qdraw
def start(str):
	n=0        # counter
	res=32     # resolution of sin
	
	# x-axis:
	qcad.rsPyAddLine(0, 0, 2*math.pi, 0)
	while n<2*math.pi:
		qcad.rsPyAddLine(n, 0, n, -0.05)
		n+=math.pi/4

	# y-axis:
	qcad.rsPyAddLine(0, -1, 0, 1)

	# sinus
	n=0.0
	step=(2*math.pi)/res
	while n<2*math.pi:
		qcad.rsPyAddLine(n, math.sin(n), n+step, math.sin(n+step))
		n+=step
	return(1)
示例#6
0
def start(str):
    n = 0  # counter
    res = 32  # resolution of sin

    # x-axis:
    qcad.rsPyAddLine(0, 0, 2 * math.pi, 0)
    while n < 2 * math.pi:
        qcad.rsPyAddLine(n, 0, n, -0.05)
        n += math.pi / 4

    # y-axis:
    qcad.rsPyAddLine(0, -1, 0, 1)

    # sinus
    n = 0.0
    step = (2 * math.pi) / res
    while n < 2 * math.pi:
        qcad.rsPyAddLine(n, math.sin(n), n + step, math.sin(n + step))
        n += step
    return (1)