Contraction Transform

  • Thread starter MikeLizzi
  • Start date
  • #1
238
6
Hi folks,

This is my first post here. I hope this is the right forum for this question.

I am trying to come up with a linear transform to that will take as input a vector (x, y, z) and output a vector that is scaled in the direction of another vector.

For example:
Suppose I have the corners of a square defined by the four vectors
(4, 4, 0)
(-4, 4, 0)
(-4, -4, 0)
(4, -4, 0)

I want to scale those vectors by 50% in the direction specified by the vector < 1, 1, 0 >

I want to end up with the four vectors
(2, 2, 0)
(-4, 4, 0)
(-2, -2, 0)
(4, -4, 0)

The initial square has been “squashed” by 50% in the northeast/southwest direction.
Can anybody come up with a transform for that?
 

Answers and Replies

  • #2
HallsofIvy
Science Advisor
Homework Helper
41,833
964
So you want a matrix of the form
[tex]\begin{pmatrix}a & b & c \\ d & e & f \\ g & h & i\end{pmatrix}[/tex]
such that
[tex]\begin{pmatrix}a & b & c \\ d & e & f \\ g & h & i\end{pmatrix}\begin{pmatrix}4 \\ 4 \\ 0\end{pmatrix}= \begin{pmatrix}2 \\ 2 \\ 0\end{pmatrix}[/tex]
That gives the three equations 4a+ 4b= 2, 4d+ 4e= 2, and 4g+ 4h= 0.

You also want
[tex]\begin{pmatrix}a & b & c \\ d & e & f \\ g & h & i\end{pmatrix}\begin{pmatrix}-4 \\ 4 \\ 0\end{pmatrix}= \begin{pmatrix}-4 \\ 4 \\ 0\end{pmatrix}[/tex]
That gives the three equations -4a+ 4b= -4, -4d+ 4e= 4, -4g+ 4h= 0.

Doing the same with the other two points will give you a total of twelve equations for the 9 values, a, b, c, d, e, f, g, h, and i. But I think you will find the last three redundant. Once you have the first three points, the requirement that the figure be a parallelogram fixes the fourth.
 
Last edited by a moderator:
  • #3
238
6
Thank you HallsofIvy.

But I’m looking for a formula that will convert any vector. I will be using this formula in a computer program that will contract any shape by any amount in any direction.
This is my current strategy:

For any given point (x, y, z), direction vector (vx, vy, vz) and scale g;
Rotate the point so that its x-axis lines up with the direction vector.
That means two separate rotations for a point in 3d.
Then multiply the x value by the scale.
Then back out the two rotations in reverse order.

I built the following:
Matrix A rotates the point about the Z-axis
Matrix B rotates the point about the X-axis
Matrix C scales only the x dimension.
Matrix D is the inverse of B
Matrix E is the inverse of A

So if P (x, y, z) is the input and P’ (x’, y’, z’) is the output I have
P’ = [E][D][C][A]P
Unfortunately, the strategy is not working.
 
  • #4
534
1
So you want a matrix T that scales by a factor of g along the vector v, while leaving everything orthogonal to v fixed. That is, Tv = gv, and Tu = u for all u orthogonal to v. You now have the eigenvalues and eigenspaces of T. Since the eigenspaces are orthogonal, to find T all you need is an orthogonal matrix Q such that Qv is on the first coordinate (x) axis; then you'll have T = QTDQ, where D = diag(g, 1, ..., 1) is the diagonal matrix of eigenvalues.

Observe that since your eigenvalues are real and eigenspaces are orthogonal, T will be a symmetric matrix.
 
  • #5
238
6
So you want a matrix T that scales by a factor of g along the vector v, while leaving everything orthogonal to v fixed. That is, Tv = gv, and Tu = u for all u orthogonal to v. You now have the eigenvalues and eigenspaces of T. Since the eigenspaces are orthogonal, to find T all you need is an orthogonal matrix Q such that Qv is on the first coordinate (x) axis; then you'll have T = QTDQ, where D = diag(g, 1, ..., 1) is the diagonal matrix of eigenvalues.

Observe that since your eigenvalues are real and eigenspaces are orthogonal, T will be a symmetric matrix.

This sounds great, adriank, but what does Q look like? I'm thinking it has to be a transform that rotates v into the x-axis. And the inverse of Q would rotate it back. I got something that works when u and v are two dimensional vectors.

But my three dimensional attempt fails.
 
  • #6
238
6
I think I got it!

My problem was more to do with the syntax of the programming language.

Thank you all.
 

Related Threads on Contraction Transform

  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
8
Views
2K
Replies
3
Views
2K
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
4
Views
1K
  • Last Post
Replies
1
Views
3K
  • Last Post
Replies
3
Views
951
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
2
Views
1K
Top