3
$\begingroup$

In my last Graphic mid-term, the exam contained a Transformation Matrices problem, its statement was:

Question

Rotate the following ladder to form a DNA-shaped ladder using a transformation matrix.

enter image description here

Notes

  • The ladder base must be kept as it is without any rotating.
  • The ladder lies in the x-y plane.
  • The total rotating angle should equal 540 degrees.
  • The ladder step width = 2 * ladder step height (This image isn't drawn to scale).
  • Assume that the curves are straight lines.

First Idea

When I first read the problem statement, I thought of this basic trivial solution:

  1. Translate the ladder such that the ladder's base is on the origin and the y-axis halves the ladder.
  2. Rotate all points by the required angle which depends on the current point y value.
  3. Translate the ladder back to it rotation.

Assume that $T(x,y)$ is the transformation matrix that will take care of translation to the origin and its inverse will return the ladder back to its original location, and $R_y(\theta)$ is the rotation matrix around y-axis to perform the rotation to achieve the DNA-shaped ladder.

If we calculate $\theta = 540/12 = 45$ degrees, then we need to rotate as following:

  • 1st step by $0$ degrees (to maintain the fixed-base condition).
  • 2nd step by $45$ degrees.
  • 3rd step by $90 = (2*45)$ degrees.

The problem

I couldn't apply this solution and put it into valid transformation matrix because referring to my previous knowledge (and the logic behind transformation matrices too), I recalled that we cannot put variables (e.g. y) inside the cos, sin functions inside the rotation matrix. Then I thought of another solution if I used power to the rotation matrix by the value of y this will give me the same effect but I also couldn't put this idea into a transformation matrix.

So, to conclude the problem we have 2 ways for achieving this (which I think aren't valid):

  1. $\begin{bmatrix}\cos(y\theta)&0&\sin(y\theta)&0\\0&1&0&0\\-\sin(y\theta)&0&\cos(y\theta)&0\\0&0&0&1\end{bmatrix}$

And the final answer would be: $P' = (T(x,y))^{-1} R(45) T(x,y) P$

  1. $\begin{bmatrix}\cos(\theta)&0&\sin(\theta)&0\\0&1&0&0\\-\sin(\theta)&0&\cos(\theta)&0\\0&0&0&1\end{bmatrix}$

And the final answer would be: $P' = (T(x,y))^{-1} (R(45))^{y} T(x,y) P$

Doctor's solution

My doctor was a big supporter of the first solution and he said this is the correct transformation matrix to solve such problems.

The real question

  • Do any of these solutions achieve the required result while maintaining the transformation matrix concepts (i.e. avoid equations and direct substitutions and instead use matrices operations)?

  • If both solutions are wrong, can you kindly guide me to the valid solution?

  • If one of the solutions above is correct, can you please explain why?

$\endgroup$
  • 1
    $\begingroup$ A transform like this is not a linear transform! $\endgroup$ – joojaa Nov 18 '16 at 15:13
3
$\begingroup$

You can't perform this transformation by applying constant transformation matrix to the ladder model since it's not linear transformation like joojaa said in the comments. What you would have to do instead is to define the transformation as a function of height as you have done in both of your proposals.

So both of your proposals are kind of correct, except for the typo in second one where you should use $R$ instead of $T$ that you raise to power of y. However, you might have difficulties raising a matrix to non-integer power (requires expansion of Taylor series, AFAIK), so your first proposal is much more practical.

$\endgroup$
  • $\begingroup$ If I define the transformation as a function of height, how can I then express it as a matrix ? or does this mean that I cannot keep it as the traditional matrix form and there should be input inside my rotation matrix? and if so, can I use such matrix in OpenGL to achieve the same results? Thank you $\endgroup$ – hemoali Nov 18 '16 at 17:45
  • 2
    $\begingroup$ You can't express it as a constant matrix, because that's able to do only linear transformations (rotate, translate, skew, scale). Instead you would have to create the matrix for every vertex you transform based on the y-coordinate of the vertex. $\endgroup$ – JarkkoL Nov 18 '16 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.