p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

p5.Vector explanation of setMag

Open micuat opened this issue 5 years ago • 7 comments

Actual Behaviour

in https://p5js.org/reference/#/p5.Vector

Set the magnitude of this vector to the value used for the len parameter.

Expected Behaviour

if I understand correctly

Set the magnitude of this vector to the value used for the mag parameter.

micuat avatar Sep 07 '20 12:09 micuat

That is set to match the parameter name in https://p5js.org/reference/#/p5.Vector/setMag. Changing it to be mag in both places is fine but I wonder if it would cause confusion with the mag() method in some way (maybe that's why it is named len in the first place).

limzykenneth avatar Sep 07 '20 15:09 limzykenneth

Thanks, now I see... I thought it's about mag() but in fact in the url you pointed it has len as a parameter of setMag(len). I feel it's a bit confusing in the p5.Vector page because len does not appear there. I don't know what would be a better description though :(

micuat avatar Sep 07 '20 16:09 micuat

It seems the two descriptions have to match because of how the p5.Vector class is rendered, they are fetched from the same string.

limzykenneth avatar Sep 08 '20 13:09 limzykenneth

that's what I thought after your first comment. The more I read the sentence I feel it sounds strange. What about

Set the magnitude of this vector to len (the first parameter)

is that still too wordy? do we need feedback from other people to change it?

micuat avatar Sep 08 '20 13:09 micuat

It still feels a bit off to me.

For a bit of context, the existing description is taken from Processing word for word while the setMag() in Processing's PVector class has a different description. I'm not sure about how difficult it is to seperate the two on p5.js and I'm a bit reluctant to do it now as I'm exploring refinements to the whole render proceess.

Some additional feedback would definitely be helpful.

limzykenneth avatar Sep 08 '20 13:09 limzykenneth

I think this could be simplified to just say "Set the magnitude of the vector." Maybe this is less confusing? My assumption would be that if someone is using setMag() they have wrapped their head around parameters a bit already, and would be able to follow the format of the documentation to use the method. But I think your proposed update to the language makes sense as well.

lmccart avatar Nov 01 '20 07:11 lmccart

I think that corrently is very clear. Magnitudes is size of the vector. Len is size from one point to another.

DavidWeiss2 avatar Apr 15 '21 23:04 DavidWeiss2

Thank you all for working on this issue. I am inviting the current Math stewards to this discussion @limzykenneth, @ericnlchen, @ChihYungChang, @bsubbaraman, @albertomancia, @JazerUCSB, @tedkmburu, @perminder-17, @Obi-Engine10, @jeanetteandrews. Would love to hear what y'all think. Thanks!

Qianqianye avatar Oct 13 '23 23:10 Qianqianye

I think the documentation wording has been changed since the original issue, in August 2023 (commit details).

The setMag() description reads:

Sets a vector's magnitude to a given value.

And the p5.Vector description introduces both the terms 'magnitude' and 'length':

Vectors have both magnitude (length) and direction.

I personally think this works, and agree with @limzykenneth's earlier point that changing the parameter name from len to mag might cause confusion with the mag() method; introducing magnitude and length as interchangeable terms seems like a good way to go about it. There is now a small typo, with (Optional) being written twice.

Do others think that the current explanations are clear enough?

bsubbaraman avatar Dec 05 '23 21:12 bsubbaraman

Addressed with recent changes

limzykenneth avatar Jan 21 '24 11:01 limzykenneth