SFML community forums

General => Feature requests => Topic started by: StormWingDelta on April 12, 2014, 11:45:38 pm

Title: Noticed something missing from the C# Vectors for SFML
Post by: StormWingDelta on April 12, 2014, 11:45:38 pm
Someone missed the +, -, +=, and -= operators. ???  Not sure if bug, forgotten about, or oops. XD

These are missing on adding numbers to vectors. 
Title: Re: Noticed something missing from the C# Vectors for SFML
Post by: zsbzsb on April 13, 2014, 01:49:40 am
Please check before posting....  the following code works just fine.

Vector2f a = new Vector2f(1, 1);
Vector2f b = new Vector2f(2, 2);
a += b;
Title: Re: Noticed something missing from the C# Vectors for SFML
Post by: G. on April 13, 2014, 01:55:35 am
These are missing on adding numbers to vectors.
I think he means
Vector2f a = new Vector2f(1, 1);
a += 3;
My knowledge of vectors is limited, but I don't know if this really has a meaning...
Title: Re: Noticed something missing from the C# Vectors for SFML
Post by: zsbzsb on April 13, 2014, 01:57:55 am
If you could show me the line (https://github.com/SFML/SFML/blob/master/include/SFML/System/Vector2.hpp) where SFML (C++) implements that I would have no problem with this suggestion.
Title: Re: Noticed something missing from the C# Vectors for SFML
Post by: Edoren on April 13, 2014, 02:40:04 am
These are missing on adding numbers to vectors.
I think he means
Vector2f a = new Vector2f(1, 1);
a += 3;
My knowledge of vectors is limited, but I don't know if this really has a meaning...
No, you can't add a scalar to a vector, just multiply or divide them.
Title: Re: Noticed something missing from the C# Vectors for SFML
Post by: StormWingDelta on April 13, 2014, 05:39:57 am
These are missing on adding numbers to vectors.
I think he means
Vector2f a = new Vector2f(1, 1);
a += 3;
My knowledge of vectors is limited, but I don't know if this really has a meaning...
No, you can't add a scalar to a vector, just multiply or divide them.

If I remember right a simple way to add a scaler would be to get the Magnitude than add to that and have the equation spit out the new vector from that new magnitude.  Just guessing right now since I saw it in Pre Cal but didn't think anything of it.  Also saw it in a few vector libs but can't find them anymore. >.>
Title: Re: Noticed something missing from the C# Vectors for SFML
Post by: Hiura on April 13, 2014, 09:26:50 am
Quote
If I remember right a simple way to add a scaler would be to get the Magnitude than add to that and have the equation spit out the new vector from that new magnitude.

That would be a scalar multiplication.

You can find here (http://en.wikipedia.org/wiki/Vector_calculus) the mathematically valid vector operators. Adding a scalar and a vector together is not one of them.
Title: Re: Noticed something missing from the C# Vectors for SFML
Post by: Nexus on April 13, 2014, 03:09:46 pm
If I remember right a simple way to add a scaler would be to get the Magnitude than add to that and have the equation spit out the new vector from that new magnitude.
That's not simple, let alone intuitive. It doesn't make sense to provide vector operators that have no mathematical meaning, even it's technically possible. The idea of operators is to provide a nice syntax for common operations, so that it's immediately clear what the code does.

Just guessing right now since I saw it in Pre Cal but didn't think anything of it.  Also saw it in a few vector libs but can't find them anymore. >.>
Maybe you should inform yourself a bit before posting a feature request :P
Title: Re: Noticed something missing from the C# Vectors for SFML
Post by: StormWingDelta on April 13, 2014, 08:13:46 pm
Quote
If I remember right a simple way to add a scaler would be to get the Magnitude than add to that and have the equation spit out the new vector from that new magnitude.

That would be a scalar multiplication.

You can find here (http://en.wikipedia.org/wiki/Vector_calculus) the mathematically valid vector operators. Adding a scalar and a vector together is not one of them.

lol now that I remember it was probably an equation to turn what would normally be added into a multiplier for scaling.  In any event oh well. XD