Image:Pythagoras.png

From Wikipedia, the free encyclopedia

Diagram illustrating Pythagoras theorem proof.

Produced by user Trainspotter using a program he wrote in the IDL language.

Program is listed below in case a modified version needs to be produced. (Program below is public domain, but IDL package itself is payware.)


a=100. ; side A
b=70.  ; side B
m=3.   ; margin around plot
s=2*m+a+b ; length of side of image
r=(a+b)/2 ; offset (in each of x,y) from centre of 
          ;     image to corner of triangle
c=m+(a+b)/2 ; position (in each of x,y) of centre of image
set_plot,'z'
device,set_res=[s,s]
tek_color
erase,1 ; white bg
c1=15. ; distance to offset characters to centre
c2=5.  ; extra y-offset for characters
d=[[0,0,a,0],[0,b,0,0]]  ; vectors to triangle vertices
d1=[[a,c1,a],[c1,b,b+1.5*c1]]/2  ; vectors to text labels
lab=['a','b','c']
cols=[0,2,4,8] ; predefined indices in tek_color
rot=[[0,-1],[1,0]] ; 90deg rotation matrix
ori=[[1,0],[0,1]]  ; current rotation matrix
for i=0,3 do begin ; loop over triangles
    pos=[c,c]+ori##[-r,-r]  ; corner of triangle (use as plot offset)
    draw=ori##d     ; relative vectors allowing for rotation
    label=ori##d1   ; (likewise)
    plots,pos[0]+draw[*,0],pos[1]+draw[*,1],/device,col=cols[i]
    xyouts,pos[0]+label[*,0],pos[1]+label[*,1]-c2,/device,col=cols[i],lab, $
      align=0.5,charsize=1.2   
    ori=rot##ori
endfor
image=tvrd()
tvlct,rr,gg,bb,/get
write_png,'pythagoras.png',image,rr,gg,bb
end

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeDimensionsUserComment
current16:03, 10 June 2003176×176 (2 KB)Trainspotter (Talk | contribs) (diagram illustrating Pythagoras theorem proof)

The following pages on the English Wikipedia link to this file (pages on other projects are not listed):