- Fix Arrays to be plotted
- Fix the formula
Rho [0.0
, 2.0]
H1
[0.0 , 5.0]
Xi
[0.0 , 1.0]
- Fix Arrays to be plotted
Maxp=101
Rho[Maxp+3]
H1[Maxp+3]
- Fix the formula
H1[i]=1./Math.sqrt(Math.pow(1.-Rho[i]*Rho[i],2)+Math.pow(2.*Xi*Rho[i],2))
dx
= (2.0-0.0)/(Maxp-1)
- Window Design
- Window Design
Drawing port
World coordinates 30. x 30. Screen
Coordinates 300 x 300
Origin
(5.,5.)
Lenght of X-axis
20.
length of Y-axis
15.
Title
"Plot of H1 anvs. Rho and Xi"
//******************************************
public class Fig011 extends Jcalcomp
//******************************************
{
//==========================================
public Fig011()
//==========================================
{
super(300,300,30.,-5.,-5.,0,0,300,300);
}
//==========================================
public void paint( Graphics g )
//==========================================
{
double
Rho[]=new double[110],
H1[]=new double[110];
double Xi=0.2;
double Xaxis=20.0,Yaxis=15.;
double Xmax=2.0,Ymax=5.0;
int Maxp=101;
double dx=Xmax/(Maxp-1);
// Calculate the values
for(int i=0;i<Maxp;i++)
{
Rho[i]=dx*i;
H1[i]=1./Math.sqrt(Math.pow(1.-Rho[i]*Rho[i],2)+
Math.pow(2.*Xi*Rho[i],2));
}
Rho[Maxp+1]=0.;Rho[Maxp+2]=Xmax/Xaxis;
H1[Maxp+1]=0.;H1[Maxp+2]=Ymax/Yaxis;
//Draw line
lline(g,0.,0.,Rho,H1,Maxp,0);
// Draw Axis
axis(g,0.,0., Xaxis/10.,Xaxis, 0.,"Rho",3,1,2,0.,.4);
axis(g,0.,0.,-Yaxis/10.,Yaxis,90.,"H1" ,2,1,2,0.,1.);
}
}
- Event handling
- Related to physical variables
import java.applet.*;
import java.awt.*;
//******************************************
public class Fig011 extends Jcalcomp
//******************************************
{
Scrollbar Xi_number;
Label Xi_title;
//==========================================
public void init()
//==========================================
{
setLayout( null );
Xi_title = new Label( "Xi"
);
Xi_title.reshape(
10, 20, 40, 20 );
add( Xi_title );
Xi_number = new Scrollbar(
Scrollbar.HORIZONTAL, 50, 0, 0, 150 );
Xi_number.setPageIncrement(
2 );
Xi_number.reshape(
50, 20, 150, 20 );
add( Xi_number );
}
//==========================================
public Fig011()
//==========================================
{
super(300,300,30.,-5.,-5.,0,0,300,300);
}
//==========================================
public boolean handleEvent( Event
event )
//==========================================
{
if (event.id == Event.SCROLL_ABSOLUTE
||
event.id == Event.SCROLL_LINE_DOWN
||
event.id == Event.SCROLL_LINE_UP ||
event.id == Event.SCROLL_PAGE_DOWN ||
event.id == Event.SCROLL_PAGE_UP )
{
repaint();
return true;
}
return super.handleEvent( event );
}
//==========================================
public void paint( Graphics g )
//==========================================
{
double
Rho[]=new double[110],
H1[]=new double[110];
double Xi
= Xi_number.getValue()*.01;
double Xaxis=20.0,Yaxis=15.;
double Xmax=2.0,Ymax=5.0;
int Maxp=101;
double dx=Xmax/(Maxp-1);
// Calculate the values
for(int i=0;i<Maxp;i++)
{
Rho[i]=dx*i;
H1[i]=1./Math.sqrt(Math.pow(1.-Rho[i]*Rho[i],2)+
Math.pow(2.*Xi*Rho[i],2));
}
Rho[Maxp+1]=0.;Rho[Maxp+2]=Xmax/Xaxis;
H1[Maxp+1]=0.;H1[Maxp+2]=Ymax/Yaxis;
//Draw line
lline(g,0.,0.,Rho,H1,Maxp,0);
// Draw Axis
axis(g,0.,0., Xaxis/10.,Xaxis, 0.,"Rho",3,1,2,0.,.4);
axis(g,0.,0.,-Yaxis/10.,Yaxis,90.,"H1" ,2,1,2,0.,1.);
// Draw Xi
g.setColor(Color.red);
symbol(g,5.,Yaxis+1.,"Xi=");
number(g,8.,Yaxis+1.,1.,Xi,0.,2);
}
}
For capturing, Windows has image cutting short cut, which is Fn
+ PrtSc.
After capturing the browsing image or whole screen image, you can paste
it in some image retouch software. You should save each image of
formula as Gif(*.gif) or Jpeg(*.jpg) format after cutting and editting.
In HTML documents, it is easy to insert such a image.
You have to, however, add some source code into your Java source,
if you want to arrange the image in the applet. See next Tip.
3D space in this class library is just corresponding to world coordinate.
There is no 3D user's coordinate.
You have to convert the value of you model to 3D space coordinates.
In many cases, 3D graph is drawn in the isometric projection. This class
library has both of isometric and perspective projection method.
\documentclass[b5paper,fleqn,leqno]{jarticle}
\begin{document}
\[p(t)=\hat{p}\sin \Omega t \\ \]
\[u(t)= \hat{u} \sin (\Omega t - \delta) \\ \]
\[\hat{u}=\frac{\hat{p}}{k}H_1 \\ \]
\[H_1=\frac{1}{\sqrt{[1-\rho^2]^2 + [2 \xi \rho]^2}} \\ \]
\[\tan \delta = \frac{2 \xi \rho}{1- \rho^2} \\ \]
\[\rho=\frac{\Omega}{\omega} \\ \]
\[\omega=\sqrt{\frac{k}{m}} \\ \]
\[\xi=\frac{c}{2 \omega m} \\ \]
\newpage
\[H_1|_{max}=\frac{1}{2 \xi \sqrt{1-\xi^2}} \\ \]
\[\rho_{max}=\sqrt{1-2 \xi^2}\]
\end{document}
import java.applet.*;
import java.awt.*;
//******************************************
public class Fig012 extends Jcalcomp
//******************************************
{
Image Eq1_27;
//==========================================
public Fig012()
//==========================================
{
super(300,300,30.,-5.,-5.,0,0,300,300);
}
//==========================================
public void init()
//==========================================
{
Eq1_27=getImage(getDocumentBase(),"eq1_27.gif");
}
//==========================================
public void paint( Graphics g )
//==========================================
{
double
Rho[]=new double[110],
H1[]=new double[110];
double Xi = 0.4;
double Xaxis=20.0,Yaxis=15.;
double Xmax=2.0,Ymax=5.0;
int Maxp=101;
double dx=Xmax/(Maxp-1);
setLayout( null );
// Calculate the values
for(int i=0;i<Maxp;i++)
{
Rho[i]=dx*i;
H1[i]=1./Math.sqrt(Math.pow(1.-Rho[i]*Rho[i],2)+
Math.pow(2.*Xi*Rho[i],2));
}
Rho[Maxp+1]=0.;Rho[Maxp+2]=Xmax/Xaxis;
H1[Maxp+1]=0.;H1[Maxp+2]=Ymax/Yaxis;
//Draw line
lline(g,0.,0.,Rho,H1,Maxp,0);
// Draw Axis
axis(g,0.,0., Xaxis/10.,Xaxis, 0.,"Rho",3,1,2,0.,.4);
axis(g,0.,0.,-Yaxis/10.,Yaxis,90.,"H1" ,2,1,2,0.,1.);
// Draw Xi
g.setColor(Color.red);
symbol(g,5.,Yaxis+1.,"Xi=");
number(g,8.,Yaxis+1.,1.,Xi,0.,2);
symbol(g,-5.,-5.,"Fig012");
// Draw Equation
g.drawImage(Eq1_27,0,0,this);
}
}