Skip to content

Instantly share code, notes, and snippets.

@pedrofracassi
Created April 18, 2022 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedrofracassi/cd6ea56248207b3a019bcbd2164cd181 to your computer and use it in GitHub Desktop.
Save pedrofracassi/cd6ea56248207b3a019bcbd2164cd181 to your computer and use it in GitHub Desktop.
import numpy as np
import math
import matplotlib.pyplot as plt
min = 0
max = 2*math.pi
precision = 3
def x(t):
return round(12*math.cos(t) - 6*math.cos(6*t), precision)
def y(t):
return round(12*math.sin(t) - 6*math.sin(6*t), precision)
pontos = []
autointerseccao = []
for t in np.arange(min, max, 1/10**precision):
ponto = (x(t), y(t), t)
for p in pontos[:-5]:
if math.isclose(p[0], ponto[0], abs_tol=(1/10**precision)*20) and math.isclose(p[1], ponto[1], abs_tol=(1/10**precision)*20):
autointerseccao.append((p[2], t))
pontos.append(ponto)
@pedrofracassi
Copy link
Author

[(0.874, 1.6400000000000001),
 (2.13, 2.896),
 (3.387, 4.1530000000000005),
 (4.644, 5.41),
 (0.383, 5.9)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment