RainyBread7

复三角函数

20250425.py
"""
def complex_cosine(complex1):
    a = complex1.real
    b = complex1.imag
    
    eb = math.exp(b)
    
    return complex(math.cos(a) * (eb + 1/eb)/2, -math.sin(a) * (eb - 1/eb)/2 )

def complex_tangent(complex1):
    return complex_sine(complex1)/complex_cosine(complex1)
"""

import math
def complex_sine(complex1):
    a = complex1.real
    b = complex1.imag
    
    eb = math.exp(b)
    
    return complex(math.sin(a) * (eb + 1/eb)/2, math.cos(a) * (eb - 1/eb)/2 )

from turtle import *

pensize(5)
pencolor('blue')
penup()

i = 0
while True:#i <= 2*math.pi:
    i += math.pi/360
    #c = complex_sine(complex(i+2*math.cos(2*i), 5+math.sin(1*i))) #图案1
    c = complex_sine(complex(i+2*math.cos(10*i), 5+math.sin(5*i))) #图案2
    goto(c.imag, c.real)
    
    if i == math.pi/360: pendown()
    if i >= math.pi * 2:
        penup()
        hideturtle()