A superellipse is a geometric figure defined as the set of all points (x, y) with



 





|


x
a


|


n



+


|


y
b


|


n



=
1
,


{\displaystyle \left|{\frac {x}{a}}\right|^{n}\!+\left|{\frac {y}{b}}\right|^{n}\!=1,}




where n, a, and b are positive numbers.



Task
Draw a superellipse with n = 2.5, and a = b = 200




 
//Aamrun, 29th June 2022
 
float a = 200, b = 200, n = 2.5;
float i, incr = 0.001;
int xMul,yMul;
 
size(500,500);
 
stroke(#ff0000);
 
for(i=0;i<2*PI;i+=incr){
  if(PI/2<i && i<3*PI/2)
    xMul = -1;
  else
    xMul = 1;
  if(PI<i && i<2*PI)
    yMul = -1;
  else
    yMul = 1;
 
  ellipse(width/2 + xMul * a*pow(abs(cos(i)),2/n),height/2 + yMul * b*pow(abs(sin(i)),2/n),1,1);
}
 
 