Example #1
0
void ModelToRadialCorrection::getModel(const RadialCorrection &correction, double in[]) const
{
    int count = 0;
    if (mGuessCenter) {
        in[count++] = correction.mParams.principalX();
        in[count++] = correction.mParams.principalY();
    }
    if (mGuessTangent) {
        in[count++] = correction.mParams.tangentialX();
        in[count++] = correction.mParams.tangentialY();
    }

    if (mEvenDegreeOnly) {
        for (int i = 0; i < mPolynomialDegree / 2; i++)
        {
            if (i * 2 + 1 < (int)correction.mParams.mKoeff.size())
            {
                in[count++] = correction.mParams.mKoeff[i * 2 + 1];
            } else {
                in[count++] = 0.0;
            }
        }
    } else {
        int i = 0;
        int copyDegree = CORE_MIN(mPolynomialDegree, (int)correction.mParams.mKoeff.size());
        for (; i < copyDegree; i++)
        {
            in[count++] = correction.mParams.mKoeff[i];
        }
        for (; i < mPolynomialDegree; i++)
        {
            in[count++] = 0.0;
        }
    }
}
Example #2
0
unsigned long buffernode_read(struct buffer_node* node, char* data, unsigned long sz)
{
	unsigned long all, l;

	all = node->in - node->out;
	if (all < sz) return -1;

	l = CORE_MIN(sz, node->size - (node->out&(node->size - 1)));
	memcpy(data, node->buf + (node->out&(node->size - 1)), l);
	memcpy(data + l, data, sz - l);

	node->out += sz;
	return 0;
}
Example #3
0
unsigned long buffernode_write(struct buffer_node* node, char* data, unsigned long sz)
{
	unsigned long all, l;

	assert(node);
	all = node->size - (node->in - node->out);
	if (all < sz) return -1;

	l = CORE_MIN(sz, node->size - (node->in&(node->size - 1)));
	memcpy(node->buf + (node->in&(node->size - 1)), data, l);
	memcpy(node->buf, data + l, sz - l);

	node->in += sz;
	return 0;
}