<html xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<style>
v/:* {behavior:url(#default#VML);}
o/:* {behavior:url(#default#VML);}
x/:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<SCRIPT LANGUAGE="JScript">
function Deg2Rad(Deg)
{
return (Deg*Math.PI / 180);
}
//点x1,y1 经转af(角度)后的新点坐标x2,y2:(椭圆圈不能以此公式计算)
// x2 = x1 * Math.cos(alfa1) - (this.Earth0Rx/this.Earth0Ry) * y1 * Math.sin(alfa1);
// y2 = y1 * Math.cos(alfa1) + (this.Earth0Ry/this.Earth0Rx) * x1 * Math.sin(alfa1);
function rotpnt(x1,y1,af)
{
this.x1 = x1;
this.y1 = y1;
var alfa1 = Deg2Rad(af);
this.x2 = this.x1 * Math.cos(alfa1) - this.y1 * Math.sin(alfa1);
this.y2 = this.x1 * Math.sin(alfa1) + this.y1 * Math.cos(alfa1);
}
//-----------------------------------------------------------------------------------
var originx0 = screen.availWidth/2; //取屏幕宽度中值
var originy0 = screen.availHeight - 120; //取屏幕高度-120
var originz0 = 0; //Z值
var flag = 0;
function line0(id,x0,y0,z0,from,to,strokecolor,strokeweight,dashstyle,rotation)
{
var left,top,width,height
var str = "";
left = x0;
top = y0;
str = str +"<v:line id="+id+" style='position:absolute; ";
str = str +" left:"+left+"px;top:"+top+"px;Z-INDEX:"+z0+";rotation:"+rotation+";";
str = str +" from='"+from+"' to='"+to+"' ";
str = str +" strokeweight='"+strokeweight+"pt;' strokecolor='"+strokecolor+"'> ";
str = str +" <v:stroke dashstyle='"+dashstyle+"' /> ";
str = str +"</v:line>";
document.write(str);
}
function line1(id,fromx,fromy,tox,toy)
{
x0 = fromx;
y0 = fromy;
x1 = tox-fromx;
y1 = toy-fromy;
line0(id,x0,y0,3002,"0,0",""+x1+","+y1,"#00FFFF",1,"Dot",0)
}
function ellipsering(id,x0,y0,z0,ra,rb,filled,fillcolor,stroked,strokecolor,strokeweight,rotation)
{
var left,top,width,height
var str = "";
left = x0-ra;
top = y0-rb
width = 2*ra;
height = 2*rb;
str = str +"<v:oval id="+id+" style='position:absolute; ";
str = str +" left:"+left+"px;top:"+top+"px;width:"+width+"px;height:"+height+"px; ";
str = str +" rotation:"+rotation+";z-index:"+z0+"' filled='"+filled+"' fillcolor="+fillcolor+" stroked='"+stroked+"' strokecolor="+strokecolor+" ";
str = str +" strokeweight="+strokeweight+"pt> ";
str = str +" <v:stroke dashstyle='solid'/> ";
str = str +"</v:oval>";
document.write(str);
}
function Parabola(a,b)
{
this.ValueA = a;
this.ValueB = Math.abs(b);
this.num = 0;
this.curr = 0;
}
function DrawParabola()
{
var x0,y0,x1,y1,A,B,num;
// 抛物线虚点:
A = this.ValueA;
B = this.ValueB;
// clockwise: left -> right
// anticlockwise: right -> left
this.CurrentX = 0 - (this.ValueB * this.BallDirection);
this.num = 0;
for(x0=(-B*this.BallDirection);
x0*this.BallDirection <= B;
x0 += this.BallStep*this.BallDirection) {
this.num++;
y0 = A * ( x0 * x0 - B * B);
ellipsering("p"+this.num,
originx0 + x0,
originy0 + y0,
this.num,
this.BallRadius,
this.BallRadius,
"t","#000222","t","#000222",0,"0");
}
window.status = ""+x0+"; "+y0+"; "+this.num;
}
function BallMove() {
var x0,y0,x1,y1,A,B,num;
A = this.ValueA;
B = this.ValueB;
if(flag==1) setTimeout("Parabola0.BallWv()",this.BallInterval); //控制转停
x0 = this.CurrentX;
y0 = A * ( x0 * x0 - B * B);
x1 = originx0 + x0;
y1 = originy0 + y0;
this.curr++;
obj1 = "p"+this.curr;
// eval(obj1+".style.left=" + x1);
// eval(obj1+".style.top=" + y1);
// 一个球着色时,前一个球的色要复原:
if (this.curr == 1)
{
obj2 = "p"+this.num;
eval(obj2+".fillcolor='#000222'");
eval(obj2+".style.zIndex="+1);
}
if ((this.curr > 1) && (this.curr <= this.num))
{
obj2 = "p"+this.curr;
eval(obj2+".fillcolor='##FF0000'");
eval(obj2+".style.zIndex="+this.num);
obj2 = "p"+(this.curr-1);
eval(obj2+".fillcolor='#000222'");
eval(obj2+".style.zIndex="+1);
}
if (this.curr >= this.num)
{
start.disabled=0;
this.curr = 0;
flag = 0;
}
window.status = ""+x0+"; "+y0+";"+this.curr;
}
</SCRIPT>
</head>
<body scroll=yes style="font-family: 宋体; background-color: #000000; color:#FF00FF">
抛物运动轨迹线。可改变大小,颜色等。(谷来成,2007-3-18)<br><br><br>
<button οnclick="flag=1;Parabola0.BallWv();this.disabled=1;" id='start'>开始</button>开始运动。<br>
<button οnclick="flag=0;start.disabled=0;">停止</button>停止运动。<br>
<button οnclick="flag=0;Parabola0.BallWv();start.disabled=0;">分解</button>分解动作。
<script>
line0("vml1",originx0-400,originy0,3001,"0,0","800,0","#0000FF",1,"Dot",0)
line0("vml2",originx0,originy0-600,3002,"0,0","0,620","#0000FF",1,"Dot",0)
// y = a * (x^2 - b^2)
Parabola0 = new Parabola(0.0115,200);
Parabola.prototype.Dp = DrawParabola;
Parabola.prototype.BallWv = BallMove;
//Parabola:
Parabola.prototype.BallRadius = 12; //小球的半径
Parabola.prototype.BallAngle = 0; //小球运动时的起始角
Parabola.prototype.BallStep = 5; //小球运动时的步长
Parabola.prototype.BallDirection = 1; //小球运动方向(1:clockwise,-1:anticlockwise)
Parabola.prototype.BallInterval = 60; //时间间隔
Parabola0.Dp();
</script>
</body>
</html>