# inlength + infield + outfield

< Previous | Next >

#### logos

##### Member
"inlength , infield , outfield" refiriéndose al campo de la informática y no al de beísbol.

logos.

• #### Alpha0ne

##### Senior Member
Estos términos que citas son "javascript" No se traducen, es código universal.
javascript
Ejemplo:

Below is an image with of a sinus wave with some terms added.

Descriptive sinus wave

Those that know the sinus function know that it returns values in the interval [1,-1] so we should multiply this value with the amplitude. We should also set the period so that the user can have more than one wave top in their SinusPath. The phase shift property is used for starting the wave at a different point than (0,0) (actually a different angle than 0). Below is the modify SinusPath.

function SinusPath(inLength, inAmplitude, inPeriod, inPhase, steps) {
this.x = 0;
this.y = 0; //This will be set later
this.step = int_step;
this.reset = int_reset;

//Private code
var length = inLength;
var currentStep = 0;
var amplitude = inAmplitude;
if (inPeriod > 0)
var period = inPeriod;
else
var period = length;
var phase = inPhase;

if (steps <= 0) { // When steps are less than one
var totalSteps = 0; // there shouldn't be any animation.
this.x = length; // Just set the position to
} // the end position
else
var totalSteps = steps;
this.y = getY();

function int_step() {
if (currentStep <= totalSteps && totalSteps > 0) {
this.x = currentStep / totalSteps * length;
this.y = getY();
currentStep++;
return true;
}
else
return false;
}

function int_reset() {
currentStep = 0;
if (totalSteps > 0)
this.x = 0;
else
this.x = length;
this.y = getY();
}

function getY() {
var q;
if (totalSteps > 0)
q = currentStep / totalSteps;
else
q = 0;
return amplitude * Math.sin(2 * Math.PI * length/period *
q - phase/length*2*Math.PI);
}
}
SinusPath.prototype = new Path();

< Previous | Next >