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

Author Topic: Rotations About Center of Circle  (Read 1217 times)

0 Members and 1 Guest are viewing this topic.

sfmllmfs

  • Newbie
  • *
  • Posts: 2
    • View Profile
Rotations About Center of Circle
« on: October 04, 2020, 02:13:49 am »
Hi there,

This is likely a very dumb question, but based on reading all the documentation of rotation and setOrigin, this isn't clear to me why the behavior is such.

My question is based on the code below. It seems as  though rotating a circle about its center (which seemingly should have no effect) actually moves the circle!

sf::CircleShape c( 100.f );
c.setOrigin(sf::Vector2f(100.f, 100.f));
c.rotate(45);

If I render that graphic, the circle is not fixed. Instead, only its bottom right quadrant appears in the window.

What happened here?

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
Re: Rotations About Center of Circle
« Reply #1 on: October 04, 2020, 09:48:20 am »
Hey.

This has nothing to do with rotation, but with origin and position. Origin is not only the center of rotation, but also the anchor of its position.
If your origin and position are 0, 0 and 0, 0 then the circle top left "corner" will be in 0, 0
If your origin and position are 100, 100 and 0, 0 then the circle top left "corner" will be in -100, -100 thus you'll only see its bottom right quadrant.

(and your assumption is right, when you rotate a circle around its center, you won't see any change)

sfmllmfs

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Rotations About Center of Circle
« Reply #2 on: October 06, 2020, 07:11:12 pm »
Oh.

That would explain a lot!  :-[

Thanks for pointing that out!!!

 

anything