Skip to content

scipy.spatial.transform.Rotation Integration #392

Open
@Elyasnz

Description

Vector Version

1.1.1.post1

Python Version

3.10.9

OS / Environment

OS: KAli Linux 2023.3
Environment: scipy==1.11.1

Describe the bug

First of all thanks for the awesome work on the library

there are some errors with Rotation.apply

these are some ways to reproduce

from scipy.spatial.transform import Rotation
from vector import VectorObject3D, VectorNumpy3D

v_object = VectorObject3D(x=1, y=0, z=0)
v_array = VectorNumpy3D({"x": [1], "y": [0], "z": [0]})
r = Rotation.from_quat((0, 0, 1, 1))

# _r = r.as_quat()
# print(v.rotate_quaternion(_r[3], _r[0], _r[1], _r[2]))
# Returns: VectorObject3D(x=0.0, y=0.9999999999999998, z=0.0)

# print(r.apply(v_object))  # Raises: IndexError(tuple index out of range)
print(r.apply(v_object.__array__().tolist()))
# Returns: [0. 1. 0.]

# print(r.apply(v_array))  # Raises: ValueError(Expected input of shape (3,) or (P, 3), got (1,).)
print(r.apply(v_array.tolist()))
# Returns: [[0. 1. 0.]]

I think it would be a good idea to add rotate method to Vector that accepts the Rotation instance as input and applies the rotation on Vector

from scipy.spatial.transform import Rotation

def rotate(self, rot: Rotation):
    pass

Any additional but relevant log output

No response

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions