Skip to content

Method to normalize zero vectors #2269

@Yu266426

Description

@Yu266426

Description
When normalizing a vector, it is necessary to first check it is not of length zero, otherwise the program will crash.

The game engine bevy has a method for its Vecs that is normalize_or_zero() that allows you to normalize a vector that is potentially of length zero, where it returns a zero vector if that is the case, otherwise normalizing it.

I think this would be useful to have in pygame, as it saves having to type an extra line pretty much every time you want to normalize a vector.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions