javascript dissapearing object on canvas
<p>I am writing a script to draw an image of the sun, and have an image of the earth orbit around it.</p>

<p>I have defined a planet class as so:</p>

<pre><code>function planet(name, size, rotateRate, startx, starty, colour, scale, oRad, oAng, oSpd){//container class for planets
this.name = name;
this.rotateRate = rotateRate;
this.x = startx;
this.y = starty;
this.colour = colour;
this.scale = scale;
this.size = size;
this.orbitRadius= oRad;
this.orbitAngle = oAng;
this.orbitSpeed = oSpd;
this.drawByArc = 
    function drawArcCircle(){//draws circles using the arc method
        context.save();
        context.strokeStyle = '#000000';
        context.fillStyle = this.colour;
        context.lineWidth=3;
        context.beginPath();
        context.arc(this.x,this.y,this.size*this.scale,0,Math.PI * 2,false)
        context.stroke();
        context.fill();
        context.closePath();
        context.restore();
    }
    }
</code></pre>

<p>Now I have created two instances of the class in the program and drawn them fine using the following functions:</p>

<pre><code>function gameLoop(){//The Game Loop
var thisTime = Date.now();//current time
var deltaTime = thisTime - lastTime;//find difference, not yet used
update();
draw();
lastTime = thisTime;
setTimeout(gameLoop, 1000/60);
}

function draw(){// Draws all the objects
    drawBackground();
    Sun.drawByArc();
    Earth.drawByArc();
}

function update(){// Updates for animation
//var newRotation = this.getCurrantRotation() + (this.getRotationRate()*deltaTime);
var gSegments;
gScale = 4;
simSpeed = 10;
Sun.scale = gScale;
Earth.scale = gScale;
Earth.orbitSpeed = 360/simSpeed;
//Earth.x = Sun.x + Earth.orbitRadius * Math.cos(Earth.orbitAngle * Math.pi / 180);
//Earth.y = Sun.y - Earth.orbitRadius * Math.sin(Earth.orbitAngle * Math.pi / 180);
}
</code></pre>

<p>When i have the last two lines of the update method commented out, both circles draw fine, however when i add the final two lines in to attempt to update the earths position in orbit, when i attempt to run the code in chrome the Earth sphere vanishes!</p>

<p>Chrome debugger shows no errors so i'm at a loss as to why it occurs.</p>

<p>EDITED::</p>

<p>Well, I found that thanks to a small typing error (math.pi instead of Math.PI) my planet x and y values were becoming NaN.</p>

<p>however now my earth is stuck at at 90 degree point in its orbit and simply doesnt move, at least it draws, any ideas?</p>
