diff --git a/pylinalg/vector.py b/pylinalg/vector.py index eb85576..71fe989 100644 --- a/pylinalg/vector.py +++ b/pylinalg/vector.py @@ -105,17 +105,28 @@ def vec_transform( transformed vectors """ - matrix = np.asarray(matrix) + matrix = np.asarray(matrix, dtype="f8") if projection: - vectors = vec_homogeneous(vectors, w=w, dtype=float) - vectors @= matrix.T - vectors[..., :-1] /= vectors[..., -1, None] - vectors = vectors[..., :-1] + vectors = vec_homogeneous(vectors, w=w, dtype="f8") + if vectors.ndim == 1: + vectors = matrix @ vectors + vectors[:-1] /= vectors[-1] + vectors = vectors[:-1] + elif vectors.ndim == 2: + vectors = (matrix @ vectors.T).T + vectors = vectors[..., :-1] / vectors[..., -1, None] + else: + raise ValueError("vectors must be a 1D or 2D array") else: - vectors = np.asarray(vectors, dtype=float, copy=True) - vectors @= matrix[:-1, :-1].T - vectors += matrix[:-1, -1] + if vectors.ndim == 1: + vectors = matrix[:-1, :-1] @ vectors + matrix[:-1, -1] + elif vectors.ndim == 2: + vectors = vec_homogeneous(vectors, w=w, dtype="f8") + vectors = (matrix @ vectors.T).T + vectors = vectors[..., :-1] + else: + raise ValueError("vectors must be a 1D or 2D array") if out is None: out = vectors diff --git a/pyproject.toml b/pyproject.toml index 2554418..6f5850f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ [project] name = "pylinalg" -version = "0.6.5" +version = "0.6.6" description = "Linear algebra utilities for Python" readme = "README.md" license = { file = "LICENSE" }