For this challenge we are focusing on a set of equations used to draw different sections of the Batman logo:
- f(x) = 1.5*sqrt((‑abs(abs(x) – 1)) * abs(3 – abs(x))/((abs(x) – 1)*(3 – abs(x)))) * (1+abs(abs(x) – 3)/(abs(x)- 3)) * sqrt(1 – (x/7)^2)+(4.5+0.75 * (abs(x – 0.5)+abs(x+0.5)) – 2.75 * (abs(x-0.75)+abs(x+0.75))) * (1+abs(1 – abs(x))/(1 – abs(x)))
- g(x) = (‑3)*sqrt(1 -(x/7)^2) * sqrt(abs(abs(x) – 4)/(abs(x)-4))
- h(x) = abs(x/2) – 0.0913722 * x^2-3+sqrt(1 – (abs(abs(x) – 2) – 1)^2)
- i(x) = (2.71052+1.5 – 0.5 * abs(x) – 1.35526 * sqrt(4 – (abs(x) – 1)^2)) * sqrt(abs(abs(x) – 1)/(abs(x) – 1))
We will import two Python libraries:
- math library to use functions such as sqrt() and fabs(),
- turtle library to draw/plot on the screen using x and y coordinates.
Batman Logo:
Your Challenge
Check the following page for additional maths equations to draw heart shapes. See how you could tweak the code given above to reuse these equations and draw a heart shape on screen.