Skip to content

Normalize should not check for arbitrarily small lengths #38

Open
@deluksic

Description

I discovered a bug in my app because vec2.normalize was avoiding division by 0 by checking an arbitrarily small length:

https://github.com/greggman/wgpu-matrix/blob/main/src/vec2-impl.ts#L506

I believe it should only check for 0, by doing len || 1 for example and leave other numerical instabilities to the caller.

Situation in which this appeared is a demo app where you can zoom in a lot, so vectors become super small. That doesn't mean that these are not valid vector values that can be normalized.

(demo app in question https://deluksic.github.io/apollonian-circles/)

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions