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

Author Topic: Cartesian to Polar  (Read 1156 times)

0 Members and 1 Guest are viewing this topic.

SFMLNewGuy

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Cartesian to Polar
« on: August 19, 2020, 08:20:26 pm »
So I've always been curious about this and I was hoping someone could help me figure out what's wrong.

sf::Vector2u WindowSize{1280, 768};
sf::RectangleShape shape1{{64.f,64.f}}, shape2{{64.f,64.f}};
sf::Vector2f cart{0.f,0.f};
float scaleFactor = 1.f;
shape1.setscale(scaleFactor,scaleFactor); shape2.setscale(scaleFactor,scaleFactor);
sf::Vector2f polar{}, screen{};

while(window.open()) ...
...
screen = {(cart.x + (WINDOW_SIZE.x / 2.f)) / zoomF,
                ((WINDOW_SIZE.y / 2.f) + cart.y) / zoomF };
polar   = {(cart.x + (WINDOW_SIZE.x / 2.f)) * zoomF,
                ((WINDOW_SIZE.x / 2.f) - cart.y) * zoomF };

... up down left right        cart.x - or + = 100; cart.y - or + = 100
... num1 num2                scaleFactor + or - 0.1 and shape.setScale(scaleFactor, scaleFactor);

shape1.setPosition(polar); shape2.setPosition(cart);
draw(shape1 and shape2)
 

So I'm tracking each shapes position and I'm wondering why shape1's screen coordinates isn't being shown as (0,0)? At cartesian coordinates (0,0) it shows (480,480)  and screen coordinates (496.802, 397.442). Also when I increase the scale how come it increases off the screen at 2.f and then as you decrease continues to get bigger than shrinks down. Something with the scale isn't correct and I'm wonder if I am setting the scale correctly.

Thanks

EDIT: Also increasing the scale moves it in very unpredictable ways.
« Last Edit: August 19, 2020, 08:41:11 pm by SFMLNewGuy »

 

anything