File:Rotation with rational angle 13 over 34.svg
Page contents not supported in other languages.
Tools
General
Sister projects
In other projects
Appearance
Size of this PNG preview of this SVG file: 600 × 600 pixels. Other resolutions: 240 × 240 pixels | 480 × 480 pixels | 768 × 768 pixels | 1,024 × 1,024 pixels | 2,048 × 2,048 pixels | 709 × 709 pixels.
Original file (SVG file, nominally 709 × 709 pixels, file size: 10 KB)
This is a file from the Wikimedia Commons. The description on its description page there is shown below. |
Summary
DescriptionRotation with rational angle 13 over 34.svg |
English: rotation with rational angle 13 over 34 |
Date | |
Source | Own work |
Author | Adam majewski |
Other versions |
|
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.
C src code
/*
c console program based on :
cpp code by Claudio Rocchini
[[:File:Poincare_halfplane_eptagonal_hb.svg]]
http://validator.w3.org/
The uploaded document “circle.svg” was successfully checked as SVG 1.1.
This means that the resource in question identified itself as “SVG 1.1”
and that we successfully performed a formal validation using an SGML, HTML5 and/or XML
Parser(s) (depending on the markup language used).
------- git -----------------
cd existing_folder
git init
git remote add origin git@gitlab.com:adammajewski/svg_rotation.git
git add s.c
git commit -m " first commit"
git push -u origin master
-------- how to use --------
gcc s.c -Wall -lm
./a.out
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
// only internal angles !!!
// rotation angle = combinatorial rotation number = internal angle
int numerator = 13;
int denominator = 34;
const double PI = 3.1415926535897932384626433832795;
int iXmax = 1000,
iYmax = 1000,
radius,
cx,
cy;
// http://www.december.com/html/spec/color4.html
char *black = "#000000"; /* hexadecimal number as a string for svg color*/
char *white = "#FFFFFF";
char *burgundy = "#9E0508";
char *SeaGreen = "#068481";
char *turquoise= "#40E0D0";
char *red = "#FF0000";
char *navy = "#000080";
char *blue = "#0000FF";
FILE * fp;
char *filename="circle.svg";
char *comment = "<!-- sample comment in SVG file \n can be multi-line -->";
// ----------------- functions -------------------------------
#define MIN(a,b) (((a)<(b))?(a):(b))
void beginSVG(){
fp = fopen( filename,"w");
if( fp == NULL ) {printf (" file open error \n"); return ; }
fprintf(fp,
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
"%s \n "
"<svg width=\"20cm\" height=\"20cm\" viewBox=\"0 0 %d %d \"\n"
" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n",
comment,iXmax,iYmax);
printf(" begin done \n");
}
void EndSVG(){
fprintf(fp,"</svg>\n");
fclose(fp);
printf(" file %s saved \n",filename );
}
void draw_main_circle( char *stroke_c, char *fill_c)
{
// center
cx= iXmax/2;
cy = iYmax/2;
// adjust radius
radius = MIN(cx, cy)- 2*MIN(cx, cy)/10;
//
fprintf(fp,"<circle cx=\"%d\" cy=\"%d\" r=\"%d\" style=\"stroke:%s; stroke-width:2; fill:%s\"/>\n",
cx, cy, radius, stroke_c, fill_c);
// printf(" draw main circle done \n");
}
/*
<!-- Mark relevant points -->
<g stroke="black" stroke-width="3" fill="black">
<circle id="pointA" cx="100" cy="350" r="3" />
<circle id="pointB" cx="250" cy="50" r="3" />
<circle id="pointC" cx="400" cy="350" r="3" />
</g>
<!-- Label the points -->
<g font-size="30" font-family="sans-serif" fill="black" stroke="none" text-anchor="middle">
<text x="100" y="350" dx="-30">A</text>
<text x="250" y="50" dy="-10">B</text>
<text x="400" y="350" dx="30">C</text>
</g>
mark point by drawing a smalll circle
*/
void mark_point( int num, int den, char *stroke_c, char *fill_c)
{
int _cx, _cy;
int r = radius/30; // adjust radius
// compute center
double angle = 2.0*PI*(double)num/den;
// label
int length = 1+snprintf( NULL, 0, "%d %s %d", num, " / ", den ); // http://stackoverflow.com/questions/8257714/how-to-convert-an-int-to-string-in-c
char* label = malloc( length + 1 );
// center of local circle
_cx = cx + (int) round(radius*cos(angle));
_cy = iYmax - (cy + (int)round(radius*sin(angle))); // reverse Y axis
// mark point
fprintf(fp,"<circle cx=\"%d\" cy=\"%d\" r=\"%d\" style=\"stroke:%s; stroke-width:2; fill:%s\"/>\n",
_cx, _cy, r , stroke_c, fill_c);
// label
snprintf(label, length, "%d %s %d", num,"/", den); // snprintf( str, length + 1, "%d", x );
fprintf(fp,"<text x=\"%d\" y=\"%d\" style=\"font-family: Arial; font-size : 20; stroke : %s; fill : %s;\">%s</text>\n",
cx + (int) round((radius+4*r)*cos(angle)), iYmax - (cy + (int)round((radius+4*r)*sin(angle))), fill_c, fill_c, label );
free(label);
// printf(" mark point done \n");
}
void draw_line(int n1, int n2, int d, char *stroke_c){
double angle1 = 2.0*PI*(double)n1/d;
double angle2 = 2.0*PI*(double)n2/d;
int x1 = cx + (int) round(radius*cos(angle1));
int y1 = iYmax - (cy + (int)round(radius*sin(angle1))); // reverse Y axis
int x2 = cx + (int) round(radius*cos(angle2));
int y2 = iYmax - (cy + (int)round(radius*sin(angle2))); // reverse Y axis
fprintf(fp,"<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" style=\" stroke: %s; stroke-width:5\" />\n",x1, y1, x2, y2, stroke_c );
}
// ------------------------------------- main ---------------------------------------------------
int main(){
int i;
int in; // intinerary
// numerator
int n = numerator;
int new_n;
// Intinerary
char *color;
// char *0_color = red;
// char *1_color = green;
int n0max = denominator- numerator;
printf(" n0max = %d \n", n0max);
beginSVG();
draw_main_circle( black, white);
// mark points
for (i = 0; i < denominator ; i++)
{
if (n<=n0max && n>0) {color = "#FF0000"; in = 0;}else {color = "#068481"; in = 1;}
mark_point( n,denominator, black, color);
new_n = (n+numerator) % denominator; // circle map
printf(" %d %s %d = %d \n", n , "/", denominator, in);
draw_line(n, new_n, denominator, black );
n = new_n;
}
EndSVG();
return 0;
}
After runing :
./a.out > 13o34.txt
one has svg file ( above) and output :
n0max = 21 begin done 13 / 34 = 0 26 / 34 = 1 5 / 34 = 0 18 / 34 = 0 31 / 34 = 1 10 / 34 = 0 23 / 34 = 1 2 / 34 = 0 15 / 34 = 0 28 / 34 = 1 7 / 34 = 0 20 / 34 = 0 33 / 34 = 1 12 / 34 = 0 25 / 34 = 1 4 / 34 = 0 17 / 34 = 0 30 / 34 = 1 9 / 34 = 0 22 / 34 = 1 1 / 34 = 0 14 / 34 = 0 27 / 34 = 1 6 / 34 = 0 19 / 34 = 0 32 / 34 = 1 11 / 34 = 0 24 / 34 = 1 3 / 34 = 0 16 / 34 = 0 29 / 34 = 1 8 / 34 = 0 21 / 34 = 0 0 / 34 = 1 file 13o34.svg saved itinerary = 0100101001001010010100100101001001 first external angle = 4985538889 / 17179869183
Items portrayed in this file
depicts
some value
10 January 2016
image/svg+xml
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 21:38, 10 January 2016 | 709 × 709 (10 KB) | Soul windsurfer | User created page with UploadWizard |
File usage
The following 3 pages use this file:
Metadata
This file contains additional information, probably added from the digital camera or scanner used to create or digitize it.
If the file has been modified from its original state, some details may not fully reflect the modified file.
Width | 20cm |
---|---|
Height | 20cm |