PDA

View Full Version : drawing an Arc using points



chethana
10th July 2009, 12:18
Hi,
I want to draw an arc using points like p(x,y) and p1(x1,y1). Because i don't know the size of the rectangle to pass.But all drawArc functions in Qt will accept rectangle only.


Regards,
Sugandha

mcosta
10th July 2009, 13:42
An ARC cannot be defined by only two points. It's defined as a ellipse segment, so you must define the ellipse rectangle

ChrisW67
11th July 2009, 03:59
As pointed out above there is not enough information with just two points to specify an arc (presumably circular). Do you know the radius and two points, the centre and two points, or something else?

If you know the centre and radius then the bounding rectangle becomes trivial:

QRect bounds(centre.x()-radius, centre.y()-radius, 2*radius, 2*radius); You can calculate the radius if only the centre is known (you could probably use the QPoint::manhattanLength() function to approximate). You only need calculate the angle to/between the points at the centre to have the remaining arguments for QPainter::drawArc().