Ask Your Question
0

Shear Transformation

asked 2018-06-02 09:56:30 -0500

Kenny Karnama gravatar image

Hi guys, any ideas to calculate new value of length image after shear transformation ? thanks

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-06-02 20:27:27 -0500

sjhalayka gravatar image

updated 2018-06-03 12:16:41 -0500

Here is the code to apply a shear transformation (https://en.wikipedia.org/wiki/Shear_m...):

double shear = -3;

vector_3 vertex0(-0.5,  0.5, 0); // v0  v3
vector_3 vertex1(-0.5, -0.5, 0); //
vector_3 vertex2( 0.5, -0.5, 0); //
vector_3 vertex3( 0.5,  0.5, 0); // v1  v2

vertex0.x = vertex0.x + shear*vertex0.y;
vertex1.x = vertex1.x + shear*vertex1.y;
vertex2.x = vertex2.x + shear*vertex2.y;
vertex3.x = vertex3.x + shear*vertex3.y;

double width = 0;

if(shear < 0)
    width = vertex2.x - vertex0.x;
else
    width = vertex3.x - vertex1.x;

// when using a unit square,
// like we do here, 
// width == abs(shear) + 1
cout << width << endl;

image description

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-06-02 09:56:30 -0500

Seen: 377 times

Last updated: Jun 03 '18