File:Demipenteract graph ortho.svg

From testwiki
Jump to navigation Jump to search
    Original file (SVG file, nominally 800 × 800 pixels, file size: 805 bytes)

    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

    Description
    English: Othographic projection of Demipenteract (edge gragh)
    Date
    Source Own work
    Author Claudio Rocchini

    Source Code

    static int nbit( int x ) {
    	int n = 0;
    	while(x) { if(x&1) ++n; x >>= 1; }
    	return n;
    }
    
    void main() {
    	const int D  = 5; const int NV = 16; const int NE = 80;
    	double v[NV][D]; int    e[NE][2];
    	double px[NV]; double py[NV];
    		// Magic numbers
    	const double x1 = -.1464466094; const double y1 =  .3535533906;
    	const double x2 = -.1464466094; const double y2 = -.3535533906;
            const double x3 = -.3535533906; const double y3 =  .1464466094;
    	const double y4 = -.1464466094; const double x4 = -.3535533906;
    	const double x5 = 0;            const double y5 = 0;
    	const double PX[D] = {x1,x2,x3,x4,x5};
    	const double PY[D] = {y1,y2,y3,y4,y5};
    	int i,j,k,l;
    
    	for(k=0,i=0;i<(1<<D);++i) if(nbit(i)%2==0){
    		for(j=0;j<D;++j) v[k][j] = (i>>j)&1 ? 1.0 : -1.0;
    		++k;
    	}
    	assert(k==NV);
    
    	for(k=0,i=0;i<NV-1;++i) for(j=i+1;j<NV;++j) {
    		double d = 0;
    		for(l=0;l<D;++l) { double t = v[i][l]-v[j][l]; d += t*t; }
    		if(d==8) { e[k][0]=i; e[k][1]=j; ++k; }
    	}
    	
    	for(i=0;i<NV;++i){
    		px[i] = 0; for(l=0;l<D;++l) px[i] += v[i][l]*PX[l];
    		py[i] = 0; for(l=0;l<D;++l) py[i] += v[i][l]*PY[l];
    	}
    	
    	const double SX = 800; const double SY = 800;
    	const double B  = 64;  const double R  = 12;
    	
    	const double sca  = std::min((SX-2*B)/2,(SY-2*B)/2);
    	for(i=0;i<NV;++i) { px[i] = B+(px[i]+1)*sca; py[i] = B+(py[i]+1)*sca; }
    
    	FILE * fp = fopen("c:\\temp\\Demipenteract_Graph2.svg","w");
    	fprintf(fp,
    		"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
    		"<svg\n"
    		"xmlns:svg=\"http://www.w3.org/2000/svg\"\n"
    		"xmlns=\"http://www.w3.org/2000/svg\"\n"
    		"version=\"1.0\"\n"
    		"width=\"%g\"\n" "height=\"%g\"\n"
    		"id=\"Demipenteract_Graph2\">\n"
    		,SX,SY
    	);
    
    	fprintf(fp,"<g style=\"stroke:#000000;stroke-width:3;stroke-opacity:1.0;\">\n");
    	for(i=0;i<NE;++i)
    		fprintf(fp,
    			"<line x1=\"%5.1lf\" y1=\"%5.1lf\" x2=\"%5.1lf\" y2=\"%5.1lf\"/>\n"
    			,px[e[i][0]],py[e[i][0]], px[e[i][1]],py[e[i][1]]
    		);
    	fprintf(fp,"</g>\n");
    
    	fprintf(fp,"<g style=\"stroke:#000000;stroke-width:2;fill:#0000E0\">\n");
    	for(i=0;i<NV;++i)
    		fprintf(fp,"<circle cx=\"%5.1lf\" cy=\"%5.1lf\" r=\"%5.1lf\"/>\n",px[i],py[i],R);
    	fprintf(fp,"</g>\n");
    
    	fprintf(fp,"</svg>\n");
    	fclose(fp);
    }
    

    Licensing

    I, the copyright holder of this work, hereby publish it under the following licenses:
    GNU head Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.
    w:en:Creative Commons
    attribution
    This file is licensed under the Creative Commons Attribution 3.0 Unported 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.
    You may select the license of your choice.

    Captions

    Add a one-line explanation of what this file represents

    Items portrayed in this file

    depicts

    28 July 2008

    image/svg+xml

    805 byte

    68e503954893b0cb57f94b3c7e9b91bdbe13a336

    File history

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

    Date/TimeThumbnailDimensionsUserComment
    current04:17, 11 October 2021Thumbnail for version as of 04:17, 11 October 2021800 × 800 (805 bytes)wikimediacommons>Andreasl01Simplified code

    There are no pages that use this file.