SFML community forums

General => Feature requests => Topic started by: DragonRock on November 06, 2017, 02:49:24 pm

Title: [Closed] Multiplication and division assignement operators on Vector
Post by: DragonRock on November 06, 2017, 02:49:24 pm
Hi !

This feature would not bring much but I feel like it would make sense to have the operators *= and /= between two vectors. Currently, we can do this:

Code: [Select]
sf::Vector2f v1(1.0, 2.0);
sf::Vector2f v2(1.0, 2.0);
v1 = v1 * v2;

but we can't do this

Code: [Select]
sf::Vector2f v1(1.0, 2.0);
sf::Vector2f v2(1.0, 2.0);
v1 *= v2;

Is there any reason for this ?

Thank you in advance.
Title: Re: Multiplication and division assignement operators on Vector
Post by: eXpl0it3r on November 06, 2017, 02:59:27 pm
Please use the search function, this has been discussed so many times already.
Title: Re: Multiplication and division assignement operators on Vector
Post by: DragonRock on November 06, 2017, 03:19:49 pm
I tried to search the forum for "Multiplication", "Multiply" and "Multiply Assignement", and it didn't find anything (https://gist.github.com/tforgione/5d5588c34ff91cd672f49b7492c4969d/raw/5d816b1ef8ff3c042032ff2f4ff4c404ffa7ccf8/image.png). But apparently, if I click on search again, it finds result (which I didn't know before creating this feature request, sorry about that).

Anyway, after re-reading the docs, and reading the related posts, I understand why you don't want to make this function.

Sorry for the inconvenience.
Title: Re: [Closed] Multiplication and division assignement operators on Vector
Post by: Tank on November 06, 2017, 03:40:20 pm
The forum search is context-sensitive. That means when you search from the "Feature requests" board, the other boards are not searched.
Title: Re: [Closed] Multiplication and division assignement operators on Vector
Post by: DragonRock on November 06, 2017, 03:57:13 pm
Oh I see. Thanks for the information.
Title: Re: [Closed] Multiplication and division assignement operators on Vector
Post by: Hapax on November 07, 2017, 12:28:14 am
Just to clarify your original post a little:
Code: [Select]
sf::Vector2f v1(1.0, 2.0);
sf::Vector2f v2(1.0, 2.0);
v1 = v1 * v2;
is not possible.
Title: Re: [Closed] Multiplication and division assignement operators on Vector
Post by: DragonRock on November 07, 2017, 10:30:01 am
Yes, this is why I edited the post to strike the "Currently we can do".

I thought we could multiply vectors using operator* between two vectors, but not using the *= operator, so I thought that it was weird.

I initially thought that because the rust-sfml binding allows multipliying two vectors together (and also has some other operators such as vector + number, etc...)