Example #1
0
void
d_scalar_scalar_1(void)
{
    // d(x,x)?

    if (equal(p1, p2)) {
        push(one);
        return;
    }

    // d(a,x)?

    if (!iscons(p1)) {
        push(zero);
        return;
    }

    if (isadd(p1)) {
        dsum();
        return;
    }

    if (car(p1) == symbol(MULTIPLY)) {
        dproduct();
        return;
    }

    if (car(p1) == symbol(POWER)) {
        dpower();
        return;
    }

    if (car(p1) == symbol(DERIVATIVE)) {
        dd();
        return;
    }

    if (car(p1) == symbol(LOG)) {
        dlog();
        return;
    }

    if (car(p1) == symbol(SIN)) {
        dsin();
        return;
    }

    if (car(p1) == symbol(COS)) {
        dcos();
        return;
    }

    if (car(p1) == symbol(TAN)) {
        dtan();
        return;
    }

    if (car(p1) == symbol(ARCSIN)) {
        darcsin();
        return;
    }

    if (car(p1) == symbol(ARCCOS)) {
        darccos();
        return;
    }

    if (car(p1) == symbol(ARCTAN)) {
        darctan();
        return;
    }

    if (car(p1) == symbol(SINH)) {
        dsinh();
        return;
    }

    if (car(p1) == symbol(COSH)) {
        dcosh();
        return;
    }

    if (car(p1) == symbol(TANH)) {
        dtanh();
        return;
    }

    if (car(p1) == symbol(ARCSINH)) {
        darcsinh();
        return;
    }

    if (car(p1) == symbol(ARCCOSH)) {
        darccosh();
        return;
    }

    if (car(p1) == symbol(ARCTANH)) {
        darctanh();
        return;
    }

    if (car(p1) == symbol(ABS)) {
        dabs();
        return;
    }

    if (car(p1) == symbol(SGN)) {
        dsgn();
        return;
    }

    if (car(p1) == symbol(HERMITE)) {
        dhermite();
        return;
    }

    if (car(p1) == symbol(ERF)) {
        derf();
        return;
    }

    if (car(p1) == symbol(ERFC)) {
        derfc();
        return;
    }

    /*if (car(p1) == symbol(BESSELJ)) {
    	if (iszero(caddr(p1)))
    		dbesselj0();
    	else
    		dbesseljn();
    	return;
    }*/

    /*if (car(p1) == symbol(BESSELY)) {
    	if (iszero(caddr(p1)))
    		dbessely0();
    	else
    		dbesselyn();
    	return;
    }*/

    if (car(p1) == symbol(INTEGRAL) && caddr(p1) == p2) {
        derivative_of_integral();
        return;
    }

    dfunction();
}
Example #2
0
	/* compute the time of Asr */
	double compute_asr(int step, double t)  // Shafii: step=1, Hanafi: step=2
	{
		double d = sun_declination(julian_date + t);
		double g = -darccot(step + dtan(fabs(latitude - d)));
		return compute_time(g, t);
	}
	void ProgressCircle::OnDraw()
	{
		ImageBox::OnDraw();
		float progress = hclamp(this->progress, 0.0f, 1.0f);
		april::Color color = this->_getDrawColor();
		color.a = (unsigned char)(color.a * this->_getDisabledAlphaFactor());
		if (this->progressImage != NULL)
		{
			grect rect = this->_getDrawRect();
			if (progress == 1.0f)
			{
				this->progressImage->draw(rect, color);
			}
			else if (progress > 0.0f)
			{
				gvec2 p0;
				gvec2 p1;
				gvec2 splitCenter;
				gvec2 topLeft;
				gvec2 topRight;
				gvec2 bottomLeft;
				gvec2 bottomRight;
				switch (this->direction)
				{
				case Clockwise:
					splitCenter.set(1.0f, 0.5f);	topLeft.set(0.0f, 1.0f);	topRight.set(1.0f, 1.0f);	bottomLeft.set(0.0f, 0.0f);		bottomRight.set(1.0f, 0.0f);
					break;
				case Clockwise90:
					splitCenter.set(0.5f, 0.0f);	topLeft.set(1.0f, 1.0f);	topRight.set(1.0f, 0.0f);	bottomLeft.set(0.0f, 1.0f);		bottomRight.set(0.0f, 0.0f);
					break;
				case Clockwise180:
					splitCenter.set(0.0f, 0.5f);	topLeft.set(1.0f, 0.0f);	topRight.set(0.0f, 0.0f);	bottomLeft.set(1.0f, 1.0f);		bottomRight.set(0.0f, 1.0f);
					break;
				case Clockwise270:
					splitCenter.set(0.5f, 1.0f);	topLeft.set(0.0f, 0.0f);	topRight.set(0.0f, 1.0f);	bottomLeft.set(1.0f, 0.0f);		bottomRight.set(1.0f, 1.0f);
					break;
				case Counterclockwise:
					splitCenter.set(1.0f, 0.5f);	topLeft.set(0.0f, 0.0f);	topRight.set(1.0f, 0.0f);	bottomLeft.set(0.0f, 1.0f);		bottomRight.set(1.0f, 1.0f);
					break;
				case Counterclockwise90:
					splitCenter.set(0.5f, 0.0f);	topLeft.set(0.0f, 1.0f);	topRight.set(0.0f, 0.0f);	bottomLeft.set(1.0f, 1.0f);		bottomRight.set(1.0f, 0.0f);
					break;
				case Counterclockwise180:
					splitCenter.set(0.0f, 0.5f);	topLeft.set(1.0f, 1.0f);	topRight.set(0.0f, 1.0f);	bottomLeft.set(1.0f, 0.0f);		bottomRight.set(0.0f, 0.0f);
					break;
				case Counterclockwise270:
					splitCenter.set(0.5f, 1.0f);	topLeft.set(1.0f, 0.0f);	topRight.set(1.0f, 1.0f);	bottomLeft.set(0.0f, 0.0f);		bottomRight.set(0.0f, 1.0f);
					break;
				}
				harray<april::TexturedVertex> vertices;
				vertices += MAKE_VERTEX(gvec2(0.5f, 0.5f));
				vertices += MAKE_VERTEX(splitCenter);
				april::TexturedVertex vertex;
				p0 = bottomRight;
				p1 = topRight;
				if (progress > 0.125f)
				{
					vertex = MAKE_VERTEX(topRight);
					vertices += vertex;
					vertices += vertices.first();
					vertices += vertex;
					p0 = topRight;
					p1 = topLeft;
				}
				if (progress > 0.375f)
				{
					vertex = MAKE_VERTEX(topLeft);
					vertices += vertex;
					vertices += vertices.first();
					vertices += vertex;
					p0 = topLeft;
					p1 = bottomLeft;
				}
				if (progress > 0.625f)
				{
					vertex = MAKE_VERTEX(bottomLeft);
					vertices += vertex;
					vertices += vertices.first();
					vertices += vertex;
					p0 = bottomLeft;
					p1 = bottomRight;
				}
				if (progress > 0.875f)
				{
					vertex = MAKE_VERTEX(bottomRight);
					vertices += vertex;
					vertices += vertices.first();
					vertices += vertex;
					p0 = bottomRight;
					p1 = topRight;
				}
				double angle = hmodf(progress * 360.0f + 45.0f, 90.0f) - 45.0f;
				// angle will always be between -45° and 45° so there is no risk here
				float ratio = (float)dtan(angle) * 0.5f + 0.5f;
				p0 += (p1 - p0) * ratio;
				vertices += MAKE_VERTEX(p0);
				this->progressImage->draw(vertices, color);
			}
		}
		if (this->maskImage != NULL)
		{
			this->maskImage->draw(this->_getDrawRect(), color);
		}
	}