[Bf-python] normalze zero len vector
theeth at yahoo.com
Fri Oct 13 22:12:16 CEST 2006
--- Campbell Barton <cbarton at metavr.com> wrote:
> At the moment normalizing a zero length vector makes
> the vector (nan,
> nan, nan) on linux- which I had checks for in one of
> my exporters.
> however on win32 it became (-1.#INF, -1.#INF,
> -1.#INF) - which Im not
> sure how to check for.
> Could we make it that .normalize() does nothing if
> the vectors length is
> In the case of exporters, zero length normals come
> from faces with no area.
Are you sure it's really zero-length, not just really
Moreover, the easy way to check against that would be
to do this:
if v * v != 1:
That is, the scalar product of a normalized vector
will always be one (or very close to it, you might
have to use a delta value to account for floating
To go back to your original question, protecting
against zero-length vector normalizing would be
possible (in that case, that would be the wanted
behavior, IMHO), however, really small values might
cause problem too (like the infinities you
encountered), which would be harded to account if
wanted at all.
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
More information about the Bf-python