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

Author Topic: Сoordinates of all vertices  (Read 3422 times)

0 Members and 1 Guest are viewing this topic.

Lekter

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Сoordinates of all vertices
« on: December 10, 2014, 09:56:59 pm »
Hi, I have RectangleShape, how to get the global coordinates of all vertices(top-left,top-right,bottom-left,bottom-right) after rotate?
For example
  shape.setOrigin(size_a/2.f, size_b/2.f);
  shape.setPosition(windowWidth / 2, windowHeight / 2);
  shape.setSize({ size_a, size_b });
  shape.setRotation(10);
 
How to get coordinates of the all vertices?
Thanks.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Сoordinates of all vertices
« Reply #1 on: December 10, 2014, 10:05:37 pm »
Since sf::RectangleShape derives from sf::Shape you can use the two functions getPointCount() and getPoint(unsigned int).
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Lekter

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Сoordinates of all vertices
« Reply #2 on: December 10, 2014, 10:20:12 pm »
getPoint returned local coordinates, I need global.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Сoordinates of all vertices
« Reply #3 on: December 10, 2014, 10:38:10 pm »
sf::Vector2f point = rect.getTransform() * rect.getPoint(i);
Laurent Gomila - SFML developer

 

anything