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

Handle v1.div(v2) when vectors are 2D #5834

Merged
merged 2 commits into from
Oct 22, 2022

Conversation

davepagurek
Copy link
Contributor

Resolves #5821

Changes:

  • Allows the divisor's z to be 0 if the dividend's z is also 0, as this is likely a 2D vector
  • The above only applies when passing a vector as the divisor, as 2D vectors store z as 0; if explicitly passing number arguments or an array, it still will log an error if z is 0
    • Is this ok or should we use the same logic for all arguments?

PR Checklist

  • npm run lint passes
  • [Inline documentation] is included / updated
  • [Unit tests] are included / updated

@limzykenneth
Copy link
Member

The above only applies when passing a vector as the divisor, as 2D vectors store z as 0; if explicitly passing number arguments or an array, it still will log an error if z is 0

This should be fine as the other cases have the length check so we won't have the same problem as the original issue of anbiguity between 2D and 3D vector.

Can you add to the documentation as well to note this special case?

@davepagurek
Copy link
Contributor Author

Sounds good, docs are updated now!

@Qianqianye Qianqianye merged commit 9f23a7d into processing:main Oct 22, 2022
@davepagurek davepagurek deleted the fix/2d-vector-div branch October 22, 2022 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

p5.Pvector.div() tries to divide by 0, if the vector was created by createVector(x,y)
3 participants