Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Vector.is_collinear #904

Open
gumyr opened this issue Feb 15, 2025 · 2 comments
Open

Add Vector.is_collinear #904

gumyr opened this issue Feb 15, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@gumyr
Copy link
Owner

gumyr commented Feb 15, 2025

    def is_collinear(self, vec: Vector) -> bool:
        """Vectors are collinear if one is a scalar multiple of the other. A positive scalar
              indicates the same direction, while a negative scalar indicates the opposite direction.
        """
        return abs(self.dot(vec)) > 1 - TOLERANCE
@gumyr gumyr added the enhancement New feature or request label Feb 15, 2025
@gumyr gumyr added this to the Not Gating Release 1.0.0 milestone Feb 15, 2025
@snoyer
Copy link
Contributor

snoyer commented Feb 15, 2025

would it be the same as this?

def is_collinear(self, other: VectorLike, angular_tolerance: float=TOLERANCE):
    return self.wrapped.IsParallel(Vector(other).wrapped, angular_tolerance)

@gumyr
Copy link
Owner Author

gumyr commented Feb 15, 2025

Yes. Probably should add the normal and opposite methods as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants