adrianelectronics.com

"This site under construction"

Software

Software

Tuesday, September 30, 2014
In this Page I'll publish some software solutions I have found that may result interesting or useful for others. You can copy anything from here; but you are responsible for how you use it and the results of that use. I assume no liability whatsoever for how the contents published here are used and any damages that may result.

-Ellipse Equation Figures:

While working with the Ellipse Equation I found some interesting figures can be created by playing with the different factors.

They are shown in this Figure (All at once).


These are just some I could make in a little spare time; but if you really have time maybe you find others even more interesting. The names are just what they resemble to me; but that's just my artistic interpretation which is really bad by the way.

The code was written using the Processing 1.5.1 language; but the instructions were kept simple so they can easily be converted to other languages. Angles are in Degrees as most people are more familiar with them than with radians. When the program ends a copy of the page is saved in the sketch folder.

Here is the code:

//**Some figures using the ellipse equations by Adrian Fernandez (12-18-2012).
//Built with Processing 1.5.1


float Radio;                   //radial line lenght (pixels)
int Angle;                      //radial line angle (Deg)
float x;                         //x Coordinate of the radial line tip (pixels)
float y;                         //y Coordinate of the radial line tip (pixels)
float xDisplacement;     //x axis Center Displacement (pixels)
float yDisplacement;     //y axis Center Displacement (pixels)
float xRadius;               //x axis Ellipse radius (horizontal plane) (pixels)
float yRadius;               //y axis Ellipse radius (vertical plane) (pixels)

void setup()
{
size(1300,700);
background(255);
frameRate(30);
DrawRadialEllipse();
}

void draw()
{}

void DrawRadialEllipse()
{
xRadius=100;
yRadius=75; 
xDisplacement=200;
yDisplacement=300;
for(Angle=0;Angle<360+1;Angle++)  //Cone
{
Radio=xRadius*yRadius/sqrt(sq(yRadius*cos(radians(Angle)))+sq(xRadius*sin(radians(Angle))));
x=Radio*cos(radians(Angle))+xDisplacement;   
y=Radio*sin(radians(Angle))+yDisplacement;
line(x,y,0,0);
}


xDisplacement=450;
yDisplacement=450;
xRadius=140;
yRadius=80;
for(Angle=0;Angle<360+1;Angle++)    //Radial Ellipse
{
Radio=xRadius*yRadius/sqrt(sq(yRadius*cos(radians(Angle)))+sq(xRadius*sin(radians(Angle))));
x=Radio*cos(radians(Angle))+xDisplacement;   
y=Radio*sin(radians(Angle))+yDisplacement;
line(x,y,xDisplacement,yDisplacement);
}


xDisplacement=250;
yDisplacement=480;
xRadius=80;
yRadius=40;
for(Angle=0;Angle<360+1;Angle++)    //Radial Ellipse tilted +45 Deg
{
Radio=xRadius*yRadius/sqrt(sq(yRadius*cos(radians(Angle)))+sq(xRadius*sin(radians(Angle))));
x=Radio*cos(radians(Angle+45))+xDisplacement;   
y=Radio*sin(radians(Angle+45))+yDisplacement;
line(x,y,xDisplacement,yDisplacement);
}


xDisplacement=1050;
yDisplacement=480;
xRadius=80;
yRadius=40;
for(Angle=0;Angle<360+1;Angle++)    //Butterfly
{
Radio=xRadius*yRadius/sqrt(sq(yRadius*cos(radians(Angle)))+sq(xRadius*sin(radians(Angle))));
x=Radio*cos(radians(2*Angle))+xDisplacement;   
y=Radio*sin(radians(Angle-45))+yDisplacement;
line(x,y,xDisplacement,yDisplacement);
}


xDisplacement=1050;
yDisplacement=620;
xRadius=80;
yRadius=40;
for(Angle=0;Angle<360+1;Angle++)    //Vampire
{
Radio=xRadius*yRadius/sqrt(sq(yRadius*cos(radians(Angle)))+sq(xRadius*sin(radians(Angle))));
x=Radio*cos(radians(3*Angle))+xDisplacement;   
y=Radio*sin(radians(Angle/4-45))+yDisplacement;
line(x,y,xDisplacement,yDisplacement);



xDisplacement=920;
yDisplacement=70;
xRadius=80;
yRadius=40;
for(Angle=0;Angle<360+1;Angle++)    //Worm Hole
{
Radio=xRadius*yRadius/sqrt(sq(yRadius*cos(radians(Angle)))+sq(xRadius*sin(radians(Angle))));
x=Radio*cos(radians(3*Angle))+xDisplacement;   
y=Radio*sin(radians(Angle-45))+yDisplacement;
line(x,y,xDisplacement,yDisplacement);
}


xDisplacement=1200;
yDisplacement=300;
xRadius=80;
yRadius=40;
for(Angle=0;Angle<360+1;Angle++)    //Wasp
{
Radio=xRadius*yRadius/sqrt(sq(yRadius*cos(radians(Angle)))+sq(xRadius*sin(radians(Angle))));
x=Radio*cos(radians(4*Angle))+xDisplacement;   
y=Radio*sin(radians(Angle-45))+yDisplacement;
line(x,y,xDisplacement,yDisplacement);
}


xDisplacement=700;
yDisplacement=520;
xRadius=60;
yRadius=20;
int AmountofEllipses=3;    //Amount of Ellipses per 90 Deg
for(Angle=0;Angle<360+1;Angle++)    //Atom
{
Radio=xRadius*yRadius/sqrt(sq(yRadius*cos(radians(Angle)))+sq(xRadius*sin(radians(Angle))));
x=1*Radio*cos(radians(Angle+90/AmountofEllipses*Angle))+xDisplacement;    //Factor (1) changes simetry
y=1*Radio*sin(radians(Angle+90/AmountofEllipses*Angle))+yDisplacement;
ellipse(x,y,2,2);



xDisplacement=720;
yDisplacement=70;
xRadius=60;
yRadius=30;
for(Angle=0;Angle<360+1;Angle++)    //Flower.
{
Radio=xRadius*yRadius/sqrt(sq(yRadius*cos(radians(Angle)))+sq(xRadius*sin(radians(Angle))));
x=Radio*cos(radians(Angle+45*Angle))+xDisplacement;   
y=Radio*sin(radians(Angle-270))+yDisplacement;
line(x,y,xDisplacement,yDisplacement);
ellipse(x,y,3,3);
}


xDisplacement=1080;
yDisplacement=350;
xRadius=50;
yRadius=10; 
for(Angle=0;Angle<360+1;Angle++)    //Explosion (Fire Works?)
{
Radio=xRadius*yRadius/sqrt(sq(yRadius*cos(radians(Angle)))+sq(xRadius*sin(radians(Angle))));
x=Radio*cos(radians(log(Angle)+45*Angle))+xDisplacement;   
y=sq(Radio*sin(radians(Angle-270)))/10+yDisplacement/10;
stroke(0);
line(x,y,xDisplacement,yDisplacement);
ellipse(x,y,4,4);
}


xDisplacement=700;
yDisplacement=300;
xRadius=50;
yRadius=150;
for(Angle=0;Angle<360+1;Angle++)   //Cone
{
Radio=xRadius*yRadius/sqrt(sq(yRadius*cos(radians(Angle)))+sq(xRadius*sin(radians(Angle))));
x=Radio*cos(radians(Angle))+xDisplacement;   
y=Radio*sin(radians(Angle))+yDisplacement;
line(x,y,1000,300);
}


xDisplacement=450;
yDisplacement=200;
xRadius=80;
yRadius=140;
for(Angle=0;Angle<360+1;Angle++)    //Thick chain or ring
{
Radio=xRadius*yRadius/sqrt(sq(yRadius*cos(radians(Angle)))+sq(xRadius*sin(radians(Angle))));
x=Radio*cos(radians(Angle))+xDisplacement;   
y=Radio*sin(radians(Angle))+yDisplacement;
noFill();
ellipse(x,y,20,20);
}


xDisplacement=450;
yDisplacement=200;
xRadius=60;
yRadius=50;
for(Angle=0;Angle<360+1;Angle=Angle+10)   // Dotted ellipse
{
Radio=xRadius*yRadius/sqrt(sq(yRadius*cos(radians(Angle)))+sq(xRadius*sin(radians(Angle))));
x=Radio*cos(radians(Angle))+xDisplacement;   
y=Radio*sin(radians(Angle))+yDisplacement;
fill(0);
ellipse(x,y,4,4);
}


xDisplacement=580;
yDisplacement=70;
xRadius=60;
yRadius=60;
for(Angle=0;Angle<360+1;Angle=Angle+10)  //Sun
{
Radio=xRadius*yRadius/sqrt(sq(yRadius*cos(radians(Angle)))+sq(xRadius*sin(radians(Angle))));
x=Radio*cos(radians(Angle))+xDisplacement;   
y=Radio*sin(radians(Angle))+yDisplacement;
line(x,y,xDisplacement,yDisplacement);
}


xDisplacement=1200;
yDisplacement=30;
xRadius=40;
yRadius=60;
for(Angle=0;Angle<360+1;Angle=Angle+10)  //Bug
{
Radio=xRadius*yRadius/sqrt(sq(yRadius*cos(radians(Angle)))+sq(xRadius*sin(radians(Angle))));
x=Radio*cos(radians(Angle))+xDisplacement;   
y=Radio*sin(radians(Angle))+yDisplacement;
line(x,y+50,xDisplacement,yDisplacement);
}


xDisplacement=220;
yDisplacement=70;
xRadius=50;
yRadius=60;
for(Angle=0;Angle<360+1;Angle=Angle+10) //Cone with circles in the base.
{
Radio=xRadius*yRadius/sqrt(sq(yRadius*cos(radians(Angle)))+sq(xRadius*sin(radians(Angle))));
x=Radio*cos(radians(Angle))+xDisplacement;   
y=Radio*sin(radians(Angle))+yDisplacement;
noFill();
line(x,y,xDisplacement+100,yDisplacement-50);
ellipse(x,y,10,10);
}


xDisplacement=900;
yDisplacement=500;
xRadius=50;
yRadius=60;
for(Angle=30;Angle<300+1;Angle=Angle+10) //Open Cone with squares in the base.
{
Radio=xRadius*yRadius/sqrt(sq(yRadius*cos(radians(Angle)))+sq(xRadius*sin(radians(Angle))));
x=Radio*cos(radians(Angle))+xDisplacement;   
y=Radio*sin(radians(Angle))+yDisplacement;
noFill();
line(x,y,xDisplacement-100,yDisplacement+50);
rectMode(CENTER);
rect(x,y,5,5);
}


xDisplacement=0;
yDisplacement=600;
xRadius=150;
yRadius=250;
for(Angle=-10;Angle>-70-1;Angle=Angle-10)    //Paddles
{
Radio=xRadius*yRadius/sqrt(sq(yRadius*cos(radians(Angle)))+sq(xRadius*sin(radians(Angle))));
x=Radio*cos(radians(Angle))+xDisplacement;   
y=Radio*sin(radians(Angle))+yDisplacement;
line(x,y,xDisplacement,yDisplacement);
line(x,y+5,xDisplacement,yDisplacement);
line(x+30,y+5,xDisplacement,yDisplacement);
noFill();
rectMode(CORNER);
rect(x,y,30,5);
}


xDisplacement=450;
yDisplacement=600;
xRadius=150;
yRadius=50;
for(Angle=0;Angle<360+1;Angle=Angle+10)    //Ellipse of filled rectangles.
{
Radio=xRadius*yRadius/sqrt(sq(yRadius*cos(radians(Angle)))+sq(xRadius*sin(radians(Angle))));
x=Radio*cos(radians(Angle))+xDisplacement;   
y=Radio*sin(radians(Angle))+yDisplacement;
fill(0);
rectMode(CENTER);
rect(x,y,8,20);
}
save("EllipseRadialEquationFigures.png");
}

Audio Animation video here:
http://www.youtube.com/watch?v=aV1O9bP00kE&feature=youtu.be
Animation (Worm Hole)
video here:
http://www.youtube.com/watch?v=l_z_GNASIEQ
Code:
//**Ellipse equation figure animation by Adrian Fernandez (2-6-2013).
//Built with Processing 1.5.1


float Radio;              //radial line lenght (pixels)
int Angle;                //radial line angle (Deg)
float x;                  //x Coordinate of the radial line tip
float y;                  //y Coordinate of the radial line tip
float xDisplacement;        //x axis Center Displacement (pixels)
float yDisplacement;        //y axis Center Displacement in the (pixels)
float xRadius;              //x axis Ellipse radius (horizontal plane) (pixels)
float yRadius;              //y axis Ellipse radius (vertical plane) (pixels)
int i=1;
int F1=0;
int F2=0;

void setup()
{
size(800,600);
frameRate(30);
xDisplacement=400;
yDisplacement=300;
}

void draw()
{
background(255-i,i,i);
DrawWormHole();
if(i>250&&F1==0)
{
F1=1;
F2=0;
}
if(i<0&&F1==1)
{
F1=0;
F2=1;
}

if(F1==0)
{
i++;
}
else
{
i--;
}
if(F2==0)
{
xRadius=250;
yRadius=i;

}
else
{
xRadius=i;
yRadius=250;   
}
}

void DrawWormHole()   //Worm Hole Animation
{
for(Angle=0;Angle<360+1;Angle++)
{
Radio=xRadius*yRadius/sqrt(sq(yRadius*cos(radians(Angle)))+sq(xRadius*sin(radians(Angle))));
x=Radio*cos(radians(3*Angle))+xDisplacement;   
y=Radio*sin(radians(Angle-45))+yDisplacement;
strokeWeight(1);
stroke(255,0,255-i);
line(x,y,xDisplacement,yDisplacement);
fill(i,255-i,0);
noStroke();
ellipse(x,y,sqrt(i)/2,sqrt(i)/2);
}
}




Page under construction...