TransWikia.com

dilation in euclid, how to call the same function in asymptote

TeX - LaTeX Asked by ewa on March 25, 2021

I would like to draw the image of euclid dilation of square in asymptote. One square, and the other one with the corners on the middle points of the previous one.

euclid dilation of square

settings.outformat="pdf"; 
    
include graph;
include math;
import geometry;
    
size(11cm,0);
    
pen dBlack=rgb(16/255, 15/255, 13/255);
pen pp=1.1bp+dBlack;    // 
  
pair A=(-1,-1), B=(1,-1), C=(1,1), D=(-1,1);



 void drawsquare(pair A, pair B, pair C, pair D, int n)
{
 if (n == 0) {draw(A--B);} 
 else{   
    draw(A--B--C--D--cycle,pp);
pair A1= midpoint(A--B);
pair B1= midpoint(B--C);
pair C1= midpoint(C--D);
pair D1= midpoint(D--A);
drawsquare(A1,B1,C1,D1,n-1);}}

drawsquare(A,B,C,D,10);
    
shipout(bbox(2mm,invisible));

One Answer

Your figure is quite simple, so there are many ways to draw. This is a TikZ solotion

enter image description here

documentclass[tikz,border=5mm]{standalone}
begin{document}
begin{tikzpicture}[scale=2.5]
defn{10}
defmybox{(1,1) rectangle (-1,-1)}
foreach i in {0,...,n}
draw[scale=1/sqrt(2^i),rotate=i*45] mybox;
end{tikzpicture}
end{document}

and here is Asymptote one

enter image description here

// http://asymptote.ualberta.ca/
unitsize(2cm);
int n=12;
path mybox=box((-1,-1),(1,1));
for (int i=0; i<n; ++i)
draw (scale(1/sqrt(2^i))*rotate(45*i)*mybox,blue);
shipout(bbox(2mm,invisible));

Answered by Black Mild on March 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP