File:Simulatedelection.png
From testwiki
Jump to navigation
Jump to search
Simulatedelection.png (600 × 600 pixels, file size: 70 KB, MIME type: image/png)
This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.
Summary
| DescriptionSimulatedelection.png |
English: #include <stdio.h>
}
int main() { int i,j,k ; double x,y,u,v ;
int xa,ya,xb,yb,xc,yc,dx,dy,xm,ym ;
printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<svg xmlns=\"http://www.w3.org/2000/svg\"\n"
"xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
"width=\"600\" height=\"600\">\n"
"<title>A simulated election</title>\n") ;
for(i=0;i<600;i++) for(j=0;j<600;j++)
{ u = i - 300 ;
v = j - 300 ;
x = exp(-(u*u+v*v)/80000) ;
k = (int) (0.5 + 255 * (1-x) ) ;
printf("<rect width=\"1\" height=\"1\" x=\"%d\" y=\"%d\""
" style=\"fill:rgb(%d,%d,%d)\"/>\n",i,j,k,k,k) ;
}
xa = 180 ; ya = 350 ;
xb = 450 ; yb = 130 ;
xc = 420 ; yc = 430 ;
printf("<circle cx=\"%d\" cy=\"%d\" r=\"4\" fill=\"red\"/>\n",xa,ya) ;
printf("<circle cx=\"%d\" cy=\"%d\" r=\"4\" fill=\"red\"/>\n",xb,yb) ;
printf("<circle cx=\"%d\" cy=\"%d\" r=\"4\" fill=\"red\"/>\n",xc,yc) ;
printf("<circle cx=\"%d\" cy=\"%d\" r=\"4\" fill=\"yellow\"/>\n",300,300) ;
xm = (xa+xb)/2 ; ym = (ya+yb)/2 ;
dx = -(yb-ya) ; dy = (xb-xa) ;
printf("<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\"\n "
"style=\"stroke:red;stroke-width:2\"/>\n",
xm-6*dx,ym-6*dy,xm+6*dx,ym+6*dy) ;
xm = (xb+xc)/2 ; ym = (yb+yc)/2 ;
dx = -(yc-yb) ; dy = (xc-xb) ;
printf("<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\"\n "
"style=\"stroke:red;stroke-width:2\"/>\n",
xm-6*dx,ym-6*dy,xm+6*dx,ym+6*dy) ;
xm = (xc+xa)/2 ; ym = (yc+ya)/2 ;
dx = -(ya-yc) ; dy = (xa-xc) ;
printf("<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\"\n "
"style=\"stroke:red;stroke-width:2\"/>\n",
xm-6*dx,ym-6*dy,xm+6*dx,ym+6*dy) ;
printf("<text x=\"%d\" y=\"%d\" fill=\"red\">A</text>\n",(int)xa-6,(int)ya+20) ;
printf("<text x=\"%d\" y=\"%d\" fill=\"red\">B</text>\n",(int)xb-6,(int)yb+20) ;
printf("<text x=\"%d\" y=\"%d\" fill=\"red\">C</text>\n",(int)xc-6,(int)yc+20) ;
printf("<text x=\"294\" y=\"320\" fill=\"yellow\">O</text>\n") ;
printf("<text x=\"40\" y=\"520\" fill=\"red\">A–C–B</text>\n") ;
printf("<text x=\"380\" y=\"560\" fill=\"red\">C–A–B</text>\n") ;
printf("<text x=\"540\" y=\"420\" fill=\"red\">C–B–A</text>\n") ;
printf("<text x=\"540\" y=\"100\" fill=\"red\">B–C–A</text>\n") ;
printf("<text x=\"260\" y=\"40\" fill=\"red\">B–A–C</text>\n") ;
printf("<text x=\"20\" y=\"90\" fill=\"red\">A–B–C</text>\n") ;
printf("</svg>\n") ; |
| Date | |
| Source | Own work |
| Author | Colin.champion |
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Captions
A 3-way election under a 2-D spatial model
Items portrayed in this file
depicts
27 June 2021
72,031 byte
600 pixel
600 pixel
image/png
ee8a4e7e4ebf08f747569e3e17a6d591fb70dc1d
File history
Click on a date/time to view the file as it appeared at that time.
| Date/Time | Thumbnail | Dimensions | User | Comment | |
|---|---|---|---|---|---|
| current | 08:37, 12 July 2021 | 600 × 600 (70 KB) | wikimediacommons>Colin.champion | larger font, paler background |
File usage
The following page uses this file:
