octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Implementing view


From: Michael Goffioul
Subject: Re: Implementing view
Date: Tue, 9 Nov 2010 08:24:36 +0000

2010/11/8 Jordi Gutiérrez Hermoso <address@hidden>:
> 2010/11/8 logari81 <address@hidden>:
>
>> Hi, have you seen the following matlab documentation?
>>
>> http://www.mathworks.com/help/techdoc/ref/viewmtx.html
>>
>> it seems quite complete.
>
> Yes, but they only describe in broad strokes how T is built. I'm
> trying to reverse engineer it based on what people tell me that Matlab
> does. Or do you understand why the transformation matrix includes
> translations? That page doesn't explain it.
>
>> If I 've understood right, the only feature
>> missing in the actual view implementation in octave is the possibility
>> of returning the transformation matrix T. Is this correct?
>
> It was also missing the ability to specify views by direction vectors
> instead of azimuth and elevation, but that was quite easy to
> implement.
>
> - Jordi G. H.
>

The computation of the complete transformation matrix is a complex beast
and it took me a while to reverse engineer it. The current code is in
axes::properties::update_camera. I wrote this a while ago and I don't remember
all the details, but the full transformation includes:
- plot box normalization:
    . translate to plot box origin
    . scale x/y/z to unity
- translate to plot box center
- scale according to dataaspectratio and/or plotboxaspectratio
- translate to camera position
- rotate
- apply projection (ortho or perspective)
- stretch to fit axes allocated position
- map to viewport:
    . scale to viewport size
    . translate to viewport origin

The full transformation is decomposed in several matrices that are
accessible as hidden properties of the axes object:
- x_viewtransform
- x_projectiontransform
- x_viewporttransform
- x_normrendertransform: combination of the 3 above, mapping the unit
cube to window coordinates
- x_rendertransform: full matrix, mapping data coordinates to window coordinates

The fact that translation changes when you change axis rotation is
normal as the camera
is positioned outside the axes object (otherwise some objects would be
behind you and you
wouldn't see them). By experimentation (and luck), I determined that
the camera is automatically
positioned at 5*diag(plot box) from the plot box center (iirc), in
normalized coordinates.

Hope this helps.
Michael.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]