Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

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 = vertex3.x - vertex1.x;

cout << width << endl;

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

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 = vertex3.x - vertex1.x;

cout << width << endl;
endl; // 4

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

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 = vertex3.x - vertex1.x;

cout << width << endl; // 4
4 == shear + 1

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

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 = vertex3.x - vertex1.x;

cout << width << endl; // 4 == shear + 1
width == 3 + 1 == 4

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

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 = vertex3.x - vertex1.x;

cout << width << endl; // shear + width == 3 + 1 == 4
endl;

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

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 = vertex3.x - vertex1.x;

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

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

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 = vertex3.x - vertex1.x;

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

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

double shear = 3;
-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 == shear abs(shear) + 1
cout << width << endl;

image description