2
\$\begingroup\$

I'm developing a small application using Directx intended to plot frequency spectra data in a waterfall plot. It should look like this: waterfall plot

So far, I managed to created most of the chart components(axes, title and the data can be plotted as lines or slices as the picture above). The problem now is that I could not managed to create a projection similar to that in the image. I know the projection shown in the image is an "Oblique projection" and I've tried several ways to get it:

  1. https://www.cs.unm.edu/~angel/CS433/LECTURES/CS433_17.pdf

Here, the author proposes the projection matrix as

P = M_orth * H(θ,φ)

where M_orth is an orthogonal projection matrix and H(θ,φ) is a shear matrix defined as

H(θ,φ) = 
    | 1  0  -cot(θ)  0 |
    | 0  1  -cot(φ)  0 |
    | 0  0    1      0 |
    | 0  0    0      1 |
  1. Practical C# - Chart and Graphics, Chapter 5, Pg 247

Here, the projection matrix is defined as

P(α,θ) = 
    | 1  0  cos(θ) / tan(α)  0 |
    | 0  1  sin(θ) / tan(α)  0 |
    | 0  0         0         0 |
    | 0  0         0         1 |

and the author gives two special cases:

  • Cavalier projection: alpha = 45°, 30 <= theta <= 45
  • Cabinet projection: alpha = 63.4°, 30 <= theta <= 45

But none of them have gave me good results:

enter image description here

And I don't understand why I'm getting this strange results? Any of you guys knows how to set the oblique projection properly?

Thanks in advance

\$\endgroup\$
  • 1
    \$\begingroup\$ Assume we don't have access to the book you refer to, and that we're too lazy to open the pdf you link. You should provide us the core of what you're trying to do and some code of your implementation. \$\endgroup\$ – Vaillancourt Mar 30 '16 at 12:56
  • \$\begingroup\$ The top-right and bottom-left that fade away looks like you have issues with near and far clipping planes. \$\endgroup\$ – Vaillancourt Mar 30 '16 at 12:57
  • \$\begingroup\$ GDSE doesn't do TeX, rewrite your equations in plain text. Note that the author in the PDF you linked talks about OpenGL, in which the Z range of NDC coords is [1,-1], not [0,1]. Compensate for this and ensure that you have the v*M vs M*v convention right, as well as not mixing up storage layouts. \$\endgroup\$ – Lars Viklund Apr 2 '16 at 11:38
  • 1
    \$\begingroup\$ Thanks guys for the advices. First of all, I will be more careful when posting questions here(it's my first time). Second, @LarsViklund I managed to solve the issues by using two, an orthographic projection and a shear matrix but taking into account your advice. I will post the answer tomorrow and the steps to make it work on D3D11. \$\endgroup\$ – dryleh Apr 3 '16 at 22:24
2
\$\begingroup\$

Turns out that setting the oblique projection was pretty straight forward. To make it work on D3D11, the oblique projection should be composed by two matrices:

P(α,θ) = S(α,θ) * M_orth

where

M_orth is an orthographic projection matrix and S(α,θ) the shear matrix given by:

S(α,θ) = | 1  0  0  0 |
         | 0  1  0  0 |
         | a  b  1  0 |
         | 0  0  0  1 |

with

a = cos(θ) / tan(α) 

and

b = sin(θ) / tan(α)

These are the results I've got:

Oblique projections

\$\endgroup\$

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.