[Top][All Lists]

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

Re: Re[2]: [Gnash-dev] does _height work??

From: Martin Guy
Subject: Re: Re[2]: [Gnash-dev] does _height work??
Date: Wed, 11 Oct 2006 12:39:05 +0100

Talking about the original question, would it be correct
to change the code like this:

    virtual float       get_height() const
            matrix      m = get_world_matrix();
-           float       h = m_def->get_height_local() * m.m_[1][1];
+           float       h = m_def->get_height_local() * m.get_y_scale();
            return h;
erm, without knowing what it means by "height" in this context I can't
say, and what m_def is, and what information it's trying to create.
Out of context I have no way of knowing.

matrix::get_y_scale is implemented like:

        return sqrtf(m_[1][1] * m_[1][1] + m_[1][0] * m_[1][0]);

Is this ehat it does already, or what you are proposing?

In any case I would think that scaling without rotation and rotation
without scaling are very common cases, and mul and sqrt are very slow,
so better
if (m_[1][0]==0) return fabsf(m_[1][1]);
if (m_[1][1]==0) return fabsf(m_[1][0]);
return sqrtf(m_[1][1] * m_[1][1] + m_[1][0] * m_[1][0]);
... or some hairy combination of ? and :  but the compiler should
optimise the ifs to the same thing in any case. fabsf in case they are

BTW, matrix::get_x_scale contains an additional check:

        // Are we turned inside out?
        if (get_determinant() < 0.f)
                scale = -scale;

Should it also apply to get_y_scale ?
I would have thought so, but can't be sure without poring over that
specific code to know what it is trying to achieve, and what the value
in "scale" is supposed to mean.

Again, without seeing the code and figuring out exactly what it-s
trying to do... these questions are too micro- to make sense out of

Ah, found  a comprehensible reference.
I even seem to have got it right!


reply via email to

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