API Docs for: 1.0.0
Show:

File: src/gallery-mathcanvas/js/ImaginaryPart.js

/**
 * @module gallery-mathcanvas
 */

/**********************************************************************
 * <p>Imaginary part of a complex number.</p>
 * 
 * @namespace MathFunction
 * @class ImaginaryPart
 * @extends MathFunction.FunctionWithArgs
 * @constructor
 * @param f {MathFunction}
 */

function MathImaginaryPart(
	/* MathFunction */	f)
{
	MathImaginaryPart.superclass.constructor.call(this, MathImaginaryPart.NAME, f);
}

MathImaginaryPart.NAME = 'im';

Y.extend(MathImaginaryPart, MathFunctionWithArgs,
{
	/**
	 * @method evaluate
	 * @param var_list {Object} map of variable names to values or MathFunctions
	 * @return the value of the function
	 */
	evaluate: function(
		/* map */	var_list)
	{
		var value = this.args[0].evaluate(var_list);
		return Y.ComplexMath.isComplexNumber(value) ? value.imag() : 0;
	}
});

MathFunction.ImaginaryPart = MathImaginaryPart;

MathFunction.name_map[ MathImaginaryPart.NAME ] =
{
	applyTo: function(f)
	{
		return new MathImaginaryPart(f);
	}
};