Example #1
0
void EFX::calculatePoint(qreal iterator, qreal* x, qreal* y) const
{
    switch (algorithm())
    {
    default:
    case Circle:
        *x = cos(iterator + M_PI_2);
        *y = cos(iterator);
        break;

    case Eight:
        *x = cos((iterator * 2) + M_PI_2);
        *y = cos(iterator);
        break;

    case Line:
        *x = cos(iterator);
        *y = cos(iterator);
        break;

    case Diamond:
        *x = pow(cos(iterator - M_PI_2), 3);
        *y = pow(cos(iterator), 3);
        break;

    case Lissajous:
        *x = cos((m_xFrequency * iterator) - m_xPhase);
        *y = cos((m_yFrequency * iterator) - m_yPhase);
        break;
    }

    rotateAndScale(x, y);
}
Example #2
0
/**
 * Calculate a single point in a lissajous pattern based on
 * the value of iterator (which is basically a step number)
 *
 * @note This is a static function
 *
 * @param efx The EFX function using this
 * @param iterator Step number
 * @param x Holds the calculated X coordinate
 * @param y Holds the calculated Y coordinate
 */
void EFX::lissajousPoint(EFX* efx, float iterator, float* x, float* y)
{
	*x = cos((efx->m_xFrequency * iterator) - efx->m_xPhase);
	*y = cos((efx->m_yFrequency * iterator) - efx->m_yPhase);

	rotateAndScale(x, y, efx->m_width, efx->m_height,
		       efx->m_xOffset, efx->m_yOffset, efx->m_rotation);
}
Example #3
0
/**
 * Calculate a single point in a diamond pattern based on
 * the value of iterator (which is basically a step number)
 *
 * @note This is a static function
 *
 * @param efx The EFX function using this
 * @param iterator Step number
 * @param x Holds the calculated X coordinate
 * @param y Holds the calculated Y coordinate
 */
void EFX::diamondPoint(EFX* efx, float iterator, float* x, float* y)
{
	*x = pow(cos(iterator - M_PI_2), 3);
	*y = pow(cos(iterator), 3);

	rotateAndScale(x, y, efx->m_width, efx->m_height,
		       efx->m_xOffset, efx->m_yOffset, efx->m_rotation);
}
Example #4
0
/**
 * Calculate a single point in an eight pattern based on
 * the value of iterator (which is basically a step number)
 *
 * @note This is a static function
 *
 * @param efx The EFX function using this
 * @param iterator Step number
 * @param x Holds the calculated X coordinate
 * @param y Holds the calculated Y coordinate
 */
void EFX::eightPoint(EFX* efx, float iterator, float* x, float* y)
{
	*x = cos((iterator * 2) + M_PI_2);
	*y = cos(iterator);

	rotateAndScale(x, y, efx->m_width, efx->m_height,
		       efx->m_xOffset, efx->m_yOffset, efx->m_rotation);
}
Example #5
0
void EFX::circlePoint(EFX* efx, qreal iterator, qreal* x, qreal* y)
{
	*x = cos(iterator + M_PI_2);
	*y = cos(iterator);

	rotateAndScale(x, y, efx->m_width, efx->m_height,
		       efx->m_xOffset, efx->m_yOffset, efx->m_rotation);
}
Example #6
0
/**
 * Calculate a single point in a triangle pattern based on
 * the value of iterator (which is basically a step number)
 *
 * @note This is a static function
 *
 * @param efx The EFX function using this
 * @param iterator Step number
 * @param x Holds the calculated X coordinate
 * @param y Holds the calculated Y coordinate
 */
void EFX::trianglePoint(EFX* efx, float iterator, float* x, float* y)
{
	/* TODO !!! */
	*x = cos(iterator);
	*y = sin(iterator);

	rotateAndScale(x, y, efx->m_width, efx->m_height,
		       efx->m_xOffset, efx->m_yOffset, efx->m_rotation);
}
Example #7
0
/**
 * Calculate a single point in a line pattern based on
 * the value of iterator (which is basically a step number)
 *
 * @note This is a static function
 *
 * @param efx The EFX function using this
 * @param iterator Step number
 * @param x Holds the calculated X coordinate
 * @param y Holds the calculated Y coordinate
 */
void EFX::linePoint(EFX* efx, float iterator, float* x, float* y)
{
	/* TODO: It's a simple line, I don't think we need cos() :) */
	*x = cos(iterator);
	*y = cos(iterator);

	rotateAndScale(x, y, efx->m_width, efx->m_height,
		       efx->m_xOffset, efx->m_yOffset, efx->m_rotation);
}
Example #8
0
// this function should map from 0..M_PI * 2 -> -1..1
void EFX::calculatePoint(float iterator, float* x, float* y) const
{
    switch (algorithm())
    {
    default:
    case Circle:
        *x = cos(iterator + M_PI_2);
        *y = cos(iterator);
        break;

    case Eight:
        *x = cos((iterator * 2) + M_PI_2);
        *y = cos(iterator);
        break;

    case Line:
        *x = cos(iterator);
        *y = cos(iterator);
        break;

    case Line2:
        *x = iterator / M_PI - 1;
        *y = iterator / M_PI - 1;
        break;

    case Diamond:
        *x = pow(cos(iterator - M_PI_2), 3);
        *y = pow(cos(iterator), 3);
        break;

    case Square:
        if (iterator < M_PI / 2)
        {
            *x = (iterator * 2 / M_PI) * 2 - 1;
            *y = 1;
        }
        else if (M_PI / 2 <= iterator && iterator < M_PI)
        {
            *x = 1;
            *y = (1 - (iterator - M_PI / 2) * 2 / M_PI) * 2 - 1;
        }
        else if (M_PI <= iterator && iterator < M_PI * 3 / 2)
        {
            *x = (1 - (iterator - M_PI) * 2 / M_PI) * 2 - 1;
            *y = -1;
        }
        else // M_PI * 3 / 2 <= iterator
        {
            *x = -1;
            *y = ((iterator - M_PI * 3 / 2) * 2 / M_PI) * 2 - 1;
        }
        break;

    case SquareChoppy:
        *x = round(cos(iterator));
        *y = round(sin(iterator));
        break;

    case Leaf:
        *x = pow(cos(iterator + M_PI_2), 5);
        *y = cos(iterator);
        break;

    case Lissajous:
        {
            if (m_xFrequency > 0)
                *x = cos((m_xFrequency * iterator) - m_xPhase);
            else
            {
                float iterator0 = ((iterator + m_xPhase) / M_PI);
                int fff = iterator0;
                iterator0 -= (fff - fff % 2);
                float forward = 1 - floor(iterator0); // 1 when forward
                float backward = 1 - forward; // 1 when backward
                iterator0 = iterator0 - floor(iterator0);
                *x = (forward * iterator0 + backward * (1 - iterator0)) * 2 - 1;
            }
            if (m_yFrequency > 0)
                *y = cos((m_yFrequency * iterator) - m_yPhase);
            else
            {
                float iterator0 = ((iterator + m_yPhase) / M_PI);
                int fff = iterator0;
                iterator0 -= (fff - fff % 2);
                float forward = 1 - floor(iterator0); // 1 when forward
                float backward = 1 - forward; // 1 when backward
                iterator0 = iterator0 - floor(iterator0);
                *y = (forward * iterator0 + backward * (1 - iterator0)) * 2 - 1;
            }
        }
        break;
    }

    rotateAndScale(x, y);
}