summaryrefslogtreecommitdiff
path: root/rotord/src/nodes_transform.h
diff options
context:
space:
mode:
Diffstat (limited to 'rotord/src/nodes_transform.h')
-rw-r--r--rotord/src/nodes_transform.h39
1 files changed, 28 insertions, 11 deletions
diff --git a/rotord/src/nodes_transform.h b/rotord/src/nodes_transform.h
index 8b94d33..d54b683 100644
--- a/rotord/src/nodes_transform.h
+++ b/rotord/src/nodes_transform.h
@@ -55,7 +55,7 @@ namespace Rotor {
float tY=parameters["transformY"]->value;
float oX=parameters["originX"]->value;
float oY=parameters["originY"]->value;
- float r=parameters["rotation"]->value;
+ float r=(parameters["rotation"]->value/180)*3.1415926f;
float s=parameters["scale"]->value;
//do opencv transform
@@ -90,29 +90,46 @@ namespace Rotor {
for (int i=0;i<3;i++){
dstTri[i].x=srcTri[i].x+(tX*image.w);
dstTri[i].y=srcTri[i].y+(tY*image.w); //use w for equiv coords
+ //rotate and scale around centre
+ //transform to centre
+ dstTri[i].x-=(oX*image.w);
+ dstTri[i].y-=(oY*image.w);
+
+ dstTri[i].x*=s;
+ dstTri[i].y*=s;
+
+ float dx=(dstTri[i].x*cos(r))-(dstTri[i].y*sin(r));
+ float dy=(dstTri[i].x*sin(r))+(dstTri[i].y*cos(r));
+
+ dstTri[i].x=dx;
+ dstTri[i].y=dy;
+
+ //transform back
+ dstTri[i].x+=(oX*image.w);
+ dstTri[i].y+=(oY*image.w);
}
trans_mat=getAffineTransform( srcTri, dstTri );
- //warpAffine( in->rgb, inter.rgb, trans_mat, inter.rgb.size(), filtmode, cv::BORDER_WRAP);
+ warpAffine( in->rgb, image.rgb, trans_mat, image.rgb.size(), filtmode, cv::BORDER_WRAP);
// Compute rotation matrix
//
- cv::Point centre = cv::Point( oX*image.w, oY*image.h );
+ //cv::Point centre = cv::Point( oX*image.w, oY*image.h );
- rot_mat = getRotationMatrix2D( centre, r, s );
+ //rot_mat = getRotationMatrix2D( centre, r, s );
// Do the transformation
//
//warpAffine( inter.rgb, image.rgb, rot_mat, image.rgb.size(), filtmode, cv::BORDER_WRAP);
//BORDER_WRAP
- trans_mat.resize(3);
- rot_mat.resize(3);
- trans_mat.data[8]=1.0f;
- rot_mat.data[8]=1.0f;
- out_mat=rot_mat*trans_mat;
- out_mat.resize(2);
+ //trans_mat.resize(3);
+ //rot_mat.resize(3);
+ //trans_mat.data[8]=1.0f;
+ //rot_mat.data[8]=1.0f;
+ //out_mat=rot_mat*trans_mat;
+ //out_mat.resize(2);
- warpAffine( inter, image.rgb, out_mat, image.rgb.size(), filtmode, cv::BORDER_WRAP);
+ //warpAffine( inter, image.rgb, out_mat, image.rgb.size(), filtmode, cv::BORDER_WRAP);
return &image;
}