O
oliver hadfield
Hello all
I am having a small problem wih a javascript, could anyone help me
please
1. first of all
this code requires a form f01 and textarea t01
<form name ="f01">
<textarea name="t01" rows="80" cols="50">
</textarea></form>
2. the javascript is as follows:
----------------------
function point(x,y,z){
this.x = x;
this.y = y;
this.z = z;
}
function mkPoints(){
tmp01 = new point(-50,50,-50);
tmp02 = new point(50,50,-50);
tmp03 = new point(-50,-50,-50);
tmp04 = new point(50,-50,-50);
tmp05 = new point(-50,50,50);
tmp06 = new point(50,50,50);
tmp07 = new point( -50,-50,50);
tmp08 = new point( 50, -50 ,50 );
}
function rotate(xrot,yrot){
for (i=1;i<=8;i++){
document.all["tmp_zpos0"+i] = (eval("tmp0"+i+".z") * Math.cos(yrot))
- (eval("tmp0"+i+".x") * Math.sin(yrot))
document.all["tmp0"+i+".x"] =
(eval("tmp0"+i+".z")*Math.sin(yrot))+(eval("tmp0"+i+".x")*Math.cos(yrot));
document.all["tmp0"+i+".z"] =
(eval("tmp0"+i+".y")*Math.sin(xrot))+(eval("document.all.tmp_zpos0"+i)*Math.cos(xrot));
document.all["tmp0"+i+".y"] =
(eval("tmp0"+i+".y")*Math.cos(xrot))-(document.all["tmp_zpos0"+i]*Math.sin(xrot));
document.f01.t01.value = document.f01.t01.value +
document.all["tmp0"+i+".y"] + "\n"
}
setTimeout("rotate(0.02,0.01)", 1000);
}
function runAll (){
mkPoints()
rotate(0.02,0.01)
}
--------
The problem is as follows - I am baffled as to why it appears to retun
Nan or undefined when the values are clearly are there.
Please help,
Thank you
oliverh
I am having a small problem wih a javascript, could anyone help me
please
1. first of all
this code requires a form f01 and textarea t01
<form name ="f01">
<textarea name="t01" rows="80" cols="50">
</textarea></form>
2. the javascript is as follows:
----------------------
function point(x,y,z){
this.x = x;
this.y = y;
this.z = z;
}
function mkPoints(){
tmp01 = new point(-50,50,-50);
tmp02 = new point(50,50,-50);
tmp03 = new point(-50,-50,-50);
tmp04 = new point(50,-50,-50);
tmp05 = new point(-50,50,50);
tmp06 = new point(50,50,50);
tmp07 = new point( -50,-50,50);
tmp08 = new point( 50, -50 ,50 );
}
function rotate(xrot,yrot){
for (i=1;i<=8;i++){
document.all["tmp_zpos0"+i] = (eval("tmp0"+i+".z") * Math.cos(yrot))
- (eval("tmp0"+i+".x") * Math.sin(yrot))
document.all["tmp0"+i+".x"] =
(eval("tmp0"+i+".z")*Math.sin(yrot))+(eval("tmp0"+i+".x")*Math.cos(yrot));
document.all["tmp0"+i+".z"] =
(eval("tmp0"+i+".y")*Math.sin(xrot))+(eval("document.all.tmp_zpos0"+i)*Math.cos(xrot));
document.all["tmp0"+i+".y"] =
(eval("tmp0"+i+".y")*Math.cos(xrot))-(document.all["tmp_zpos0"+i]*Math.sin(xrot));
document.f01.t01.value = document.f01.t01.value +
document.all["tmp0"+i+".y"] + "\n"
}
setTimeout("rotate(0.02,0.01)", 1000);
}
function runAll (){
mkPoints()
rotate(0.02,0.01)
}
--------
The problem is as follows - I am baffled as to why it appears to retun
Nan or undefined when the values are clearly are there.
Please help,
Thank you
oliverh