Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPainter drawArc question
Qt 6.11 is out! See what's new in the release blog

QPainter drawArc question

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 2.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    supertux
    wrote on last edited by
    #1

    Hi. I'm trying to use QPainter drawArc(const QRectF & rectangle, int startAngle, int spanAngle) for arc drawing.
    And have a problem with it.
    I have a coordinates of 3 arc points A, B, C.
    A - arc start point
    B - arc end point
    C - arc center with known radius (10).

    Question. How to calculate rectangle, startAngle and spanAngle for this arc?

    Look Arc Image

    1 Reply Last reply
    0
    • M Offline
      M Offline
      michelson
      wrote on last edited by michelson
      #2

      NOT TESTED, JUST MATH (and i hope it is correct ^^)
      eg.: Ax - x coordinate of A point, atan === ArcTan, abs === AbsoluteValue
      Rect Top Left Point: (Ax,By)
      Rect Bottom Right Point: (Cx+R,Cy+R)
      ...or minus im not sure about the coordinate system inside drawing but i think youll get the point i hope
      Remember 0 Degree is at 3 o'clock so:
      Angle to B point:
      atan( abs(By-Cy) / abs(Bx-Cx) ) * 16 (it should be in 1/16th Degree thats why *16)
      Angle to A Point:
      (-90 - atan( abs(Cx-Ax) / abs(Ay-Cy))) * 16 (90 couse 0 is at 3 o'clock, "-" because clockwise)

      http://i.imgur.com/cCMNFrc.png

      1 Reply Last reply
      0
      • S Offline
        S Offline
        supertux
        wrote on last edited by
        #3

        Arc can be located in any of the quarters. I'm drawing using coordinates from CNC file (G-Code).

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved