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

implementing rotate(w, theta) #1992

Merged
merged 8 commits into from Oct 28, 2020
Merged

Conversation

rnd-debug
Copy link
Contributor

Related to #1160

  • Implement rotate(w, theta, v)
  • Unit tests
  • Header in the code
  • Embedded docs
  • Fixed an edge case in rotationMatrix
  • Using config.predictable to return an Array or a Matrix according to the type of w vector.

Additional request: Would it be possible to mark this PR with hacktoberfest-accepted tag? 😇 (more about hacktoberfest and the reason for the tag)

@rnd-debug rnd-debug changed the title emplementing rotate(w, theta) implementing rotate(w, theta) Oct 10, 2020
@josdejong
Copy link
Owner

Thanks @rnd-debug ! I'll look into your PR later (can't keep up with all issues/PR's at this moment, but no worries).

I'll add the hacktoberfest-accepted tag right now already 😉

@josdejong josdejong added the hacktoberfest-accepted Accept for hacktoberfest, will merge later label Oct 14, 2020
Copy link
Owner

@josdejong josdejong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good and well tested @rnd-debug, thanks!

I made two small comments, one about making sure the behavior with data types is consistent with other functions.

'Array , number | BigNumber | Complex | Unit': function (w, theta) {
_validateArraySize(w, 2)
const matrixRes = multiply(rotationMatrix(theta), w)
return config.predictable ? matrixRes.toArray() : matrixRes
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far, in mathjs the behavior of functions is as follows:

  1. array in -> array out
  2. matrix in -> matrix out
  3. when array/matrix output cannot be determined from input, look at config.matrix (for example ones(3))
  4. when the output would switch to a different type, like sqrt(-4) returning a complex number 2i, look at config.predictable, when false, return a number NaN instead of changing output to a complex number.

I think here it will be good to always return an Array when the input was an Array, and the same for matrices. Does that make sense to you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Should we also update rotationMatrix(angle, rotationAxisVector) that systematically returns a Matrix today?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Should we also update rotationMatrix(angle, rotationAxisVector) that systematically returns a Matrix today?

That is a good point, yes makes sense to use the information from rotationAxisVector when provided, and use config.matrix otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, updated.

src/function/matrix/rotate.js Outdated Show resolved Hide resolved
@josdejong
Copy link
Owner

Thanks @rnd-debug for the latest updates. Looks solid 💪

@josdejong josdejong merged commit 5849038 into josdejong:develop Oct 28, 2020
@josdejong
Copy link
Owner

The new function rotate is now available in v7.6.0. Thanks again @rnd-debug .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted Accept for hacktoberfest, will merge later
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants