59 #include "allheaders.h" 95 PROCNAME(
"createMatrix2dTranslate");
97 if ((mat = (l_float32 *)LEPT_CALLOC(9,
sizeof(l_float32))) == NULL)
98 return (l_float32 *)ERROR_PTR(
"mat not made", procName, NULL);
99 mat[0] = mat[4] = mat[8] = 1;
135 PROCNAME(
"createMatrix2dScale");
137 if ((mat = (l_float32 *)LEPT_CALLOC(9,
sizeof(l_float32))) == NULL)
138 return (l_float32 *)ERROR_PTR(
"mat not made", procName, NULL);
186 l_float32 sina, cosa;
189 PROCNAME(
"createMatrix2dRotate");
191 if ((mat = (l_float32 *)LEPT_CALLOC(9,
sizeof(l_float32))) == NULL)
192 return (l_float32 *)ERROR_PTR(
"mat not made", procName, NULL);
195 mat[0] = mat[4] = cosa;
197 mat[2] = xc * (1.0 - cosa) + yc * sina;
199 mat[5] = yc * (1.0 - cosa) - xc * sina;
231 PROCNAME(
"ptaTranslate");
234 return (
PTA *)ERROR_PTR(
"ptas not defined", procName, NULL);
238 return (
PTA *)ERROR_PTR(
"ptad not made", procName, NULL);
239 for (i = 0; i < npts; i++) {
241 ptaAddPt(ptad, x + transx, y + transy);
270 PROCNAME(
"ptaScale");
273 return (
PTA *)ERROR_PTR(
"ptas not defined", procName, NULL);
277 return (
PTA *)ERROR_PTR(
"ptad not made", procName, NULL);
278 for (i = 0; i < npts; i++) {
280 ptaAddPt(ptad, scalex * x, scaley * y);
319 l_float32 x, y, xp, yp, sina, cosa;
322 PROCNAME(
"ptaRotate");
325 return (
PTA *)ERROR_PTR(
"ptas not defined", procName, NULL);
329 return (
PTA *)ERROR_PTR(
"ptad not made", procName, NULL);
332 for (i = 0; i < npts; i++) {
334 xp = xc + (x - xc) * cosa - (y - yc) * sina;
335 yp = yc + (x - xc) * sina + (y - yc) * cosa;
365 PROCNAME(
"boxaTranslate");
368 return (
BOXA *)ERROR_PTR(
"boxas not defined", procName, NULL);
398 PROCNAME(
"boxaScale");
401 return (
BOXA *)ERROR_PTR(
"boxas not defined", procName, NULL);
404 ptad =
ptaScale(ptas, scalex, scaley);
432 PROCNAME(
"boxaRotate");
435 return (
BOXA *)ERROR_PTR(
"boxas not defined", procName, NULL);
461 l_float32 vecs[3], vecd[3];
464 PROCNAME(
"ptaAffineTransform");
467 return (
PTA *)ERROR_PTR(
"ptas not defined", procName, NULL);
469 return (
PTA *)ERROR_PTR(
"transform not defined", procName, NULL);
474 return (
PTA *)ERROR_PTR(
"ptad not made", procName, NULL);
475 for (i = 0; i < npts; i++) {
476 ptaGetPt(ptas, i, &vecs[0], &vecs[1]);
499 PROCNAME(
"boxaAffineTransform");
502 return (
BOXA *)ERROR_PTR(
"boxas not defined", procName, NULL);
504 return (
BOXA *)ERROR_PTR(
"transform not defined", procName, NULL);
535 PROCNAME(
"l_productMatVec");
538 return ERROR_INT(
"matrix not defined", procName, 1);
540 return ERROR_INT(
"input vector not defined", procName, 1);
542 return ERROR_INT(
"result vector not defined", procName, 1);
544 for (i = 0; i < size; i++) {
546 for (j = 0; j < size; j++) {
547 vecd[i] += mat[size * i + j] * vecs[j];
569 l_int32 i, j, k, index;
571 PROCNAME(
"l_productMat2");
574 return ERROR_INT(
"matrix 1 not defined", procName, 1);
576 return ERROR_INT(
"matrix 2 not defined", procName, 1);
578 return ERROR_INT(
"result matrix not defined", procName, 1);
580 for (i = 0; i < size; i++) {
581 for (j = 0; j < size; j++) {
582 index = size * i + j;
584 for (k = 0; k < size; k++)
585 matd[index] += mat1[size * i + k] * mat2[size * k + j];
611 PROCNAME(
"l_productMat3");
614 return ERROR_INT(
"matrix 1 not defined", procName, 1);
616 return ERROR_INT(
"matrix 2 not defined", procName, 1);
618 return ERROR_INT(
"matrix 3 not defined", procName, 1);
620 return ERROR_INT(
"result matrix not defined", procName, 1);
622 if ((matt = (l_float32 *)LEPT_CALLOC((
size_t)size * size,
623 sizeof(l_float32))) == NULL)
624 return ERROR_INT(
"matt not made", procName, 1);
653 PROCNAME(
"l_productMat4");
656 return ERROR_INT(
"matrix 1 not defined", procName, 1);
658 return ERROR_INT(
"matrix 2 not defined", procName, 1);
660 return ERROR_INT(
"matrix 3 not defined", procName, 1);
662 return ERROR_INT(
"result matrix not defined", procName, 1);
664 if ((matt = (l_float32 *)LEPT_CALLOC((
size_t)size * size,
665 sizeof(l_float32))) == NULL)
666 return ERROR_INT(
"matt not made", procName, 1);
BOXA * boxaScale(BOXA *boxas, l_float32 scalex, l_float32 scaley)
boxaScale()
l_float32 * createMatrix2dScale(l_float32 scalex, l_float32 scaley)
createMatrix2dScale()
PTA * ptaTranslate(PTA *ptas, l_float32 transx, l_float32 transy)
ptaTranslate()
l_ok l_productMatVec(l_float32 *mat, l_float32 *vecs, l_float32 *vecd, l_int32 size)
l_productMatVec()
PTA * boxaConvertToPta(BOXA *boxa, l_int32 ncorners)
boxaConvertToPta()
PTA * ptaScale(PTA *ptas, l_float32 scalex, l_float32 scaley)
ptaScale()
l_ok ptaAddPt(PTA *pta, l_float32 x, l_float32 y)
ptaAddPt()
PTA * ptaCreate(l_int32 n)
ptaCreate()
BOXA * boxaTranslate(BOXA *boxas, l_float32 transx, l_float32 transy)
boxaTranslate()
BOXA * ptaConvertToBoxa(PTA *pta, l_int32 ncorners)
ptaConvertToBoxa()
l_int32 ptaGetCount(PTA *pta)
ptaGetCount()
l_ok l_productMat3(l_float32 *mat1, l_float32 *mat2, l_float32 *mat3, l_float32 *matd, l_int32 size)
l_productMat3()
PTA * ptaRotate(PTA *ptas, l_float32 xc, l_float32 yc, l_float32 angle)
ptaRotate()
l_ok ptaGetPt(PTA *pta, l_int32 index, l_float32 *px, l_float32 *py)
ptaGetPt()
l_ok l_productMat4(l_float32 *mat1, l_float32 *mat2, l_float32 *mat3, l_float32 *mat4, l_float32 *matd, l_int32 size)
l_productMat4()
l_ok l_productMat2(l_float32 *mat1, l_float32 *mat2, l_float32 *matd, l_int32 size)
l_productMat2()
BOXA * boxaRotate(BOXA *boxas, l_float32 xc, l_float32 yc, l_float32 angle)
boxaRotate()
PTA * ptaAffineTransform(PTA *ptas, l_float32 *mat)
ptaAffineTransform()
void ptaDestroy(PTA **ppta)
ptaDestroy()
l_float32 * createMatrix2dRotate(l_float32 xc, l_float32 yc, l_float32 angle)
createMatrix2dRotate()
l_float32 * createMatrix2dTranslate(l_float32 transx, l_float32 transy)
createMatrix2dTranslate()
BOXA * boxaAffineTransform(BOXA *boxas, l_float32 *mat)
boxaAffineTransform()