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

fixed transformVec, oneLineSummary #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ronhippler
Copy link

No description provided.

@malgorithms
Copy link
Owner

I think the change to transformVec is wrong:

transformVec: (a) ->
     # transforms a 2-item array in place
    @transformPair(a[0], a[1])

It wouldn't change it "in place" as the function is supposed to do. transformVec is supposed to modify the array that's passed to it, not return the result.

Here's the original:

transformVec: (a) ->
     # transforms a 2-item array in place
    t0 = @m00 * a[0] + @m01 * a[1] + @v0
    t1 = @m10 * a[0] + @m11 * a[1] + @v1
    a[0] = t0
    a[1] = t1

If you want it to return the modified array, you could add one more line to the bottom setting the return value to the input.

@ronhippler
Copy link
Author

yes i know. I tried it again and now it works, don't know what I missed first.

@ronhippler
Copy link
Author

now its again in place and the summery is fixed.

@@ -64,8 +64,8 @@ class affine2d
" #{@m11.toPrecision(3)}] V = (" +
"#{@v0.toPrecision(3)}, " +
" #{@v1.toPrecision(3)}) scale = " +
@getXScale().toPrecision(3) + " x " +
@getYScale().toPrecision(3)
@getXCenter().toPrecision(3) + " x " +
Copy link
Owner

Choose a reason for hiding this comment

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

I'm a little confused about this change. The printout says "scale = " and then it was previously printing getXScale() and getYScale(), but after your change it says "scale =" and then prints the center. Can you explain?

@ronhippler
Copy link
Author

There is no function getXScale(), so I thought it was a typo. But now I think its unnecessary or rather not possible to print the scale from the matrix. Wouldn't it be better to leave the printing of the scale?

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.

2 participants