Skip to content

Bug in pysiaf.utils.rotations.unit_vector_from_cartesian #408

@sanjibs

Description

@sanjibs

Running

import pysiaf.utils.rotations
pysiaf.utils.rotations.unit_vector_from_cartesian(x=0.0, y=0.0)

incorrectly throws the following error
"UnboundLocalError: local variable 'unit_vector' referenced before assignment"

The problematic line is 778 in pysiaf/utils/rotations.py which seems to be checking for valid values but in turn ignores the valid value of zero.

if np.array([x_rad]).all() and np.array([y_rad]).all():
    unit_vector = np.array([x_rad, y_rad, np.sqrt(1-(x_rad**2+y_rad**2))])

Instead should be replaced with something like

if z is None:
    unit_vector = np.array([x_rad, y_rad, np.sqrt(1-(x_rad**2+y_rad**2))])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions