
creating_a_heptagram
creating_a_heptagram.pde
/**
* Matthew Lord : 2009/05.01
* I created this to find a way in creating a heptagon. I used the following
* construction methods found on the website:
* http://home.hiwaay.net/~jalison/hepta.html
* While doing so, I used an alternative method by dividing 2 * PI by 7
* and creating a point at each division of a circle. The construction method
* on the above website is not completed in this rendition.
*/
PVector a, b, c, d, e, f, g;
PFont font;
float seventhOfPI = PI / 7;
int diameter = 40;
int radius = diameter / 2;
float a_1, b_1, c_1, d_1, e_1, f_1, g_1;
void setup( ) {
size( 1240, 720 );
font = loadFont( "AmericanTypewriter-12.vlw");
a_1 = 0.8975979 + seventhOfPI;
b_1 = 1.7951958 + seventhOfPI;
c_1 = 2.6927938 + seventhOfPI;
d_1 = 3.5903916 + seventhOfPI;
e_1 = 4.4879894 + seventhOfPI;
f_1 = 5.385587 + seventhOfPI;
g_1 = 6.283185 + seventhOfPI;
a = new PVector( sin( a_1 ) * 200, cos( a_1 ) * 200 );
b = new PVector( sin( b_1 ) * 200, cos( b_1 ) * 200 );
c = new PVector( sin( c_1 ) * 200, cos( c_1 ) * 200 );
d = new PVector( sin( d_1 ) * 200, cos( d_1 ) * 200 );
e = new PVector( sin( e_1 ) * 200, cos( e_1 ) * 200 );
f = new PVector( sin( f_1 ) * 200, cos( f_1 ) * 200 );
g = new PVector( sin( g_1 ) * 200, cos( g_1 ) * 200 );
noLoop( );
}
void draw( ) {
translate( width / 2, height / 2 ); // bring zero point to the center
background( #FFFFFF );
textFont( font );
stroke( 5 );
noFill( );
line( - width / 2, 0, width, 0 );
line( 0, - height / 2, 0, height );
for( int i = 0; i < 11; i++ ) {
noFill( );
ellipse( 0, 0 - ( i * radius ), diameter, diameter );
if( i == 0 ) {
fill( 0 );
text( "A", 0, 0 - ( i * radius ) );
} else if( i == 1 ) {
fill( 0 );
text( "B", 0, 0 - ( i * radius ) );
} else if( i == 7 ) {
fill( 0 );
text( "C", 0, 0 - ( i * radius ) );
line( 0, 0 - ( i * radius ), width, 0 - ( i * radius ) );
} else if( i == 10 ) {
fill( 0 );
text( "D", 0, 0 - ( i * radius ) );
text( "E", 0, 0 - ( ( i + 1 ) * radius ) );
noFill( );
// diameter of circle A -> D
float largeDiameter = dist( 0, 0, 0, 0 - ( i * diameter ) );
float largeRadius = largeDiameter / 2;
ellipse( 0, 0, largeDiameter, largeDiameter );
arc( 0, 0, largeDiameter + diameter, largeDiameter + diameter, TWO_PI - PI / 2, TWO_PI );
fill( 0 );
text( "F", 0 + ( largeDiameter + diameter ) / 2, 0 );
float pointG = dist( 0, 0, ( largeDiameter + diameter ) / 2, 0 ) / 2;
text( "G", pointG, 0 );
text( "H", pointG, 0 - 7 * radius );
noFill( );
triangle( 0, 0, pointG, 0 - 7 * radius, ( largeDiameter + diameter ) / 2, 0 );
line( pointG, 0, pointG, 0 - 7 * radius );
// construct the midpoint of distance A -> H ( "I" )
float a_H = dist( 0, 0, pointG, 0 - 7 * radius );
float a_Ihyp = a_H / 2;
// height of a_I
float a_Iheight = sin( radians( 51.85145318 ) ) * a_Ihyp;
// base of a_I
float a_Ibase = sqrt( sq( a_Ihyp ) - sq( a_Iheight ) );
fill( 0 );
text( "I", a_Ibase, 0 - a_Iheight );
// construct the midpoint of distance A -> H ( "J" )
float a_J = a_Ihyp / 2;
// height of a_J
float a_Jheight = sin( radians( 51.85145318 ) ) * a_J;
// base of a_J
float a_Jbase = sqrt( sq( a_J ) - sq( a_Jheight ) );
text( "J", a_Jbase, 0 - a_Jheight );
// make arc J -> K
float arcRadiusJ_K = dist( 0, 0, a_Jbase, 0 - a_Jheight );
noFill( );
ellipse( 0, 0, arcRadiusJ_K * 2, arcRadiusJ_K * 2 );
text( "K", 0, arcRadiusJ_K );
// line( 0 - width / 2, arcRadiusJ_K, width, arcRadiusJ_K );
strokeWeight( 1 );
arc( 0, 0, a_J * 2, a_J * 2, TWO_PI - PI / 2, TWO_PI );
float angleA_J = asin( a_Jheight / a_J );
//println( angleA_J );
strokeWeight( 1 );
// refine the line above
float dist3_6Segment = sqrt( sq( largeDiameter / 2 ) - sq( arcRadiusJ_K ) );
text( "6", 0 - dist3_6Segment, arcRadiusJ_K );
text( "3", dist3_6Segment, arcRadiusJ_K );
line( 0 - dist3_6Segment, arcRadiusJ_K, dist3_6Segment, arcRadiusJ_K );
// vesica pisces
// v_p diameter
float vesicaDiameter = dist( 0 - dist3_6Segment, arcRadiusJ_K, dist3_6Segment, arcRadiusJ_K ) * 2;
ellipse( 0 - dist3_6Segment, arcRadiusJ_K, vesicaDiameter, vesicaDiameter );
ellipse( dist3_6Segment, arcRadiusJ_K, vesicaDiameter, vesicaDiameter );
}
line( a.x, a.y, d.x, d.y );
line( d.x, d.y, g.x, g.y );
line( g.x, g.y, c.x, c.y );
line( c.x, c.y, f.x, f.y );
line( f.x, f.y, b.x, b.y );
line( b.x, b.y, e.x, e.y );
line( e.x, e.y, a.x, a.y );
}
}