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

Author Topic: Drawing Arcs / Circular sectors  (Read 8781 times)

0 Members and 1 Guest are viewing this topic.

farnoy

  • Newbie
  • *
  • Posts: 14
    • View Profile
Drawing Arcs / Circular sectors
« on: August 17, 2011, 10:13:03 pm »
Hi,

How to draw a http://en.wikipedia.org/wiki/Circular_sector using generic SFML shape? I haven't seen any Arc functions in Shape class and drawing lines also doesn't cover angles.

pdinklag

  • Sr. Member
  • ****
  • Posts: 330
  • JSFML Developer
    • View Profile
    • JSFML Website
Drawing Arcs / Circular sectors
« Reply #1 on: August 17, 2011, 10:18:30 pm »
You can't technically render arcs or perfect circles, you split your arc / circle / sector up into as many triangles or straight lines as you require to get your desired level of detail.

For a perfect circle and circular sectors <= 180 degrees, a convex n-gon portion will work, but circular sectors with an angle between 180 and 360 degrees could only be represented by a concave polygon, which is why you'll probably have to go the multi-triangle way.
JSFML - The Java binding to SFML.

farnoy

  • Newbie
  • *
  • Posts: 14
    • View Profile
Drawing Arcs / Circular sectors
« Reply #2 on: August 17, 2011, 10:23:42 pm »
Thanks for your response.

What do you think about finding points by this equation:  http://en.wikipedia.org/wiki/Circle#Cartesian_coordinates

Code: [Select]
x = a + r cos(t)
y = b + r sin(t)


Wouldn't this give me a good level of detail?

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Drawing Arcs / Circular sectors
« Reply #3 on: August 18, 2011, 01:54:13 am »
Quote from: "farnoy"
Thanks for your response.

What do you think about finding points by this equation:  http://en.wikipedia.org/wiki/Circle#Cartesian_coordinates

Code: [Select]
x = a + r cos(t)
y = b + r sin(t)


Wouldn't this give me a good level of detail?
That's the exact equation you need to use.
I use the latest build of SFML2

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Drawing Arcs / Circular sectors
« Reply #4 on: August 18, 2011, 08:37:59 am »
By the way, in case you use Thor, there is a Shapes::Pie() function that creates circular sectors.

You can't use a single sf::Shape reliably, since the sector may be concave and sf::Shape only supports convex shapes. That's why the Pie() function returns thor::ConcaveShape instead.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything