Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: some arithmetic operations of sf::vector missing?  (Read 3353 times)

0 Members and 1 Guest are viewing this topic.

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
some arithmetic operations of sf::vector missing?
« on: June 19, 2016, 02:07:30 pm »
Hi!

After some SFML usage I noticed that I can compile this:
sf::Vector2f(4, 4) + sf::Vector2f(2, 2)
but I can't compile this:
sf::Vector2f(4, 4) / sf::Vector2f(2, 2) //i get some errors here saying that operator "/" is not overloaded

The question is simple: how can I correct it or is it a feature?
 
P.S

my IDE is Visual Studio 2015
« Last Edit: June 19, 2016, 02:13:33 pm by Mr_Blame »

victorlevasseur

  • Full Member
  • ***
  • Posts: 206
    • View Profile
Re: some arithmetic operations of sf::vector missing?
« Reply #1 on: June 19, 2016, 02:34:57 pm »
Hi,

Dividing a vector by another one doesn't make sense. That's probably why it's not implemented (as well as the multiplication of two vectors)

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Re: some arithmetic operations of sf::vector missing?
« Reply #2 on: June 19, 2016, 02:58:49 pm »
Oh yeah, now I see it dividing is allowed only by using scalar types!
Thanks!

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: some arithmetic operations of sf::vector missing?
« Reply #3 on: June 19, 2016, 10:18:37 pm »
You might want to look at `std::valarray` or similar, depending on what you want to do.
SFML / OS X developer