octave-maintainers
[Top][All Lists]
Advanced

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

Re: How to check a 3D xform matrix is actually 2D?


From: John Swensen
Subject: Re: How to check a 3D xform matrix is actually 2D?
Date: Sun, 7 Mar 2010 20:03:20 -0500

On Mar 7, 2010, at 3:35 PM, Michael Goffioul wrote:

> Hi,
> 
> This is not really my area of expertise, so I thought asking here
> would be easier. I assume there are a few maths experts on this
> list.
> 
> I'd like to find a way to determine whether the current axes
> transformation matrix (4x4 projection matrix) is actually a 2D
> transformation. In other words, I'd like to know whether an axes
> object is actually in 2D mode (with any axes x, y, or z being
> orthogonal to the screen).
> 
> I feel there must be a way to check that using some math
> on the xform matrix, but I don't know what.
> 
> Note: the current axes transformation matrix is available in
> the property "x_rendertransform".
> 
> Michael.

First, do you know the vector representing the direction orthogonal to the 
screen?  If so, it should be as easy and doing the dot product between this 
orthogonal vector and the transformed basis vectors.  For example,

v = screen_orthogonal_vector;
e1 = [1 0 0 0]';
e2 = [0 1 0 0]';
e3 = [0 0 1 0]';

h = get(gca, 'x_rendertransform');
zz = v' * [h*e1 h*e2 h*e3];

Then, if any of these are exactly zero (or close enough for you to consider it 
orthogonal) then you can test for which one.  Also, depending on how the 
transform is represented (e.g. does it transform points from the moving frame 
to the world frame, or from the world frame to the moving frame) that may need 
to be inv(h) in the computation of zz.  Also, this is assuming that the 
transform has no shear and scaling (e.g. the last row of the transform is [0 0 
0 1]).

John Swensen






reply via email to

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