59#include <config_auto.h>
63#include "allheaders.h"
98 mat = (l_float32 *)LEPT_CALLOC(9,
sizeof(l_float32));
99 mat[0] = mat[4] = mat[8] = 1;
135 mat = (l_float32 *)LEPT_CALLOC(9,
sizeof(l_float32));
186 mat = (l_float32 *)LEPT_CALLOC(9,
sizeof(l_float32));
189 mat[0] = mat[4] = cosa;
191 mat[2] = xc * (1.0 - cosa) + yc * sina;
193 mat[5] = yc * (1.0 - cosa) - xc * sina;
226 return (
PTA *)ERROR_PTR(
"ptas not defined", __func__, NULL);
228 npts = ptaGetCount(ptas);
229 if ((ptad = ptaCreate(npts)) == NULL)
230 return (
PTA *)ERROR_PTR(
"ptad not made", __func__, NULL);
231 for (i = 0; i < npts; i++) {
232 ptaGetPt(ptas, i, &x, &y);
233 ptaAddPt(ptad, x + transx, y + transy);
263 return (
PTA *)ERROR_PTR(
"ptas not defined", __func__, NULL);
265 npts = ptaGetCount(ptas);
266 if ((ptad = ptaCreate(npts)) == NULL)
267 return (
PTA *)ERROR_PTR(
"ptad not made", __func__, NULL);
268 for (i = 0; i < npts; i++) {
269 ptaGetPt(ptas, i, &x, &y);
270 ptaAddPt(ptad, scalex * x, scaley * y);
309l_float32 x, y, xp, yp, sina, cosa;
313 return (
PTA *)ERROR_PTR(
"ptas not defined", __func__, NULL);
315 npts = ptaGetCount(ptas);
316 if ((ptad = ptaCreate(npts)) == NULL)
317 return (
PTA *)ERROR_PTR(
"ptad not made", __func__, NULL);
320 for (i = 0; i < npts; i++) {
321 ptaGetPt(ptas, i, &x, &y);
322 xp = xc + (x - xc) * cosa - (y - yc) * sina;
323 yp = yc + (x - xc) * sina + (y - yc) * cosa;
324 ptaAddPt(ptad, xp, yp);
354 return (
BOXA *)ERROR_PTR(
"boxas not defined", __func__, NULL);
356 ptas = boxaConvertToPta(boxas, 4);
358 boxad = ptaConvertToBoxa(ptad, 4);
385 return (
BOXA *)ERROR_PTR(
"boxas not defined", __func__, NULL);
387 ptas = boxaConvertToPta(boxas, 4);
388 ptad =
ptaScale(ptas, scalex, scaley);
389 boxad = ptaConvertToBoxa(ptad, 4);
417 return (
BOXA *)ERROR_PTR(
"boxas not defined", __func__, NULL);
419 ptas = boxaConvertToPta(boxas, 4);
421 boxad = ptaConvertToBoxa(ptad, 4);
443l_float32 vecs[3], vecd[3];
447 return (
PTA *)ERROR_PTR(
"ptas not defined", __func__, NULL);
449 return (
PTA *)ERROR_PTR(
"transform not defined", __func__, NULL);
452 npts = ptaGetCount(ptas);
453 if ((ptad = ptaCreate(npts)) == NULL)
454 return (
PTA *)ERROR_PTR(
"ptad not made", __func__, NULL);
455 for (i = 0; i < npts; i++) {
456 ptaGetPt(ptas, i, &vecs[0], &vecs[1]);
458 ptaAddPt(ptad, vecd[0], vecd[1]);
480 return (
BOXA *)ERROR_PTR(
"boxas not defined", __func__, NULL);
482 return (
BOXA *)ERROR_PTR(
"transform not defined", __func__, NULL);
484 ptas = boxaConvertToPta(boxas, 4);
486 boxad = ptaConvertToBoxa(ptad, 4);
514 return ERROR_INT(
"matrix not defined", __func__, 1);
516 return ERROR_INT(
"input vector not defined", __func__, 1);
518 return ERROR_INT(
"result vector not defined", __func__, 1);
520 for (i = 0; i < size; i++) {
522 for (j = 0; j < size; j++) {
523 vecd[i] += mat[size * i + j] * vecs[j];
545l_int32 i, j, k, index;
548 return ERROR_INT(
"matrix 1 not defined", __func__, 1);
550 return ERROR_INT(
"matrix 2 not defined", __func__, 1);
552 return ERROR_INT(
"result matrix not defined", __func__, 1);
554 for (i = 0; i < size; i++) {
555 for (j = 0; j < size; j++) {
556 index = size * i + j;
558 for (k = 0; k < size; k++)
559 matd[index] += mat1[size * i + k] * mat2[size * k + j];
586 return ERROR_INT(
"matrix 1 not defined", __func__, 1);
588 return ERROR_INT(
"matrix 2 not defined", __func__, 1);
590 return ERROR_INT(
"matrix 3 not defined", __func__, 1);
592 return ERROR_INT(
"result matrix not defined", __func__, 1);
594 if ((matt = (l_float32 *)LEPT_CALLOC((
size_t)size * size,
595 sizeof(l_float32))) == NULL)
596 return ERROR_INT(
"matt not made", __func__, 1);
626 return ERROR_INT(
"matrix 1 not defined", __func__, 1);
628 return ERROR_INT(
"matrix 2 not defined", __func__, 1);
630 return ERROR_INT(
"matrix 3 not defined", __func__, 1);
632 return ERROR_INT(
"result matrix not defined", __func__, 1);
634 if ((matt = (l_float32 *)LEPT_CALLOC((
size_t)size * size,
635 sizeof(l_float32))) == NULL)
636 return ERROR_INT(
"matt not made", __func__, 1);
l_ok l_productMat4(l_float32 *mat1, l_float32 *mat2, l_float32 *mat3, l_float32 *mat4, l_float32 *matd, l_int32 size)
l_productMat4()
PTA * ptaTranslate(PTA *ptas, l_float32 transx, l_float32 transy)
ptaTranslate()
BOXA * boxaAffineTransform(BOXA *boxas, l_float32 *mat)
boxaAffineTransform()
BOXA * boxaScale(BOXA *boxas, l_float32 scalex, l_float32 scaley)
boxaScale()
BOXA * boxaTranslate(BOXA *boxas, l_float32 transx, l_float32 transy)
boxaTranslate()
PTA * ptaScale(PTA *ptas, l_float32 scalex, l_float32 scaley)
ptaScale()
BOXA * boxaRotate(BOXA *boxas, l_float32 xc, l_float32 yc, l_float32 angle)
boxaRotate()
l_float32 * createMatrix2dTranslate(l_float32 transx, l_float32 transy)
createMatrix2dTranslate()
l_ok l_productMat3(l_float32 *mat1, l_float32 *mat2, l_float32 *mat3, l_float32 *matd, l_int32 size)
l_productMat3()
l_float32 * createMatrix2dScale(l_float32 scalex, l_float32 scaley)
createMatrix2dScale()
PTA * ptaAffineTransform(PTA *ptas, l_float32 *mat)
ptaAffineTransform()
l_float32 * createMatrix2dRotate(l_float32 xc, l_float32 yc, l_float32 angle)
createMatrix2dRotate()
l_ok l_productMatVec(l_float32 *mat, l_float32 *vecs, l_float32 *vecd, l_int32 size)
l_productMatVec()
PTA * ptaRotate(PTA *ptas, l_float32 xc, l_float32 yc, l_float32 angle)
ptaRotate()
l_ok l_productMat2(l_float32 *mat1, l_float32 *mat2, l_float32 *matd, l_int32 size)
l_productMat2()