Sagitta to arc angle start and span

asked 2023-07-29 07:56:12 +0200

Andr gravatar image

In c++ with Qt we have QPainterPath path;

path.moveTo(startX, startY);
path.arcTo(x, y, width, height, startAngle, spanAngle);
painter.drawPath(path);

Computing startX, startY,endX,endY:

double theta = startAngle * M_PI / 180.0;  // deg->radians
double rx = width / 2.0;
double ry = height / 2.0;
double x0 = x + rx;
double y0 = y + ry;
double startX = x0 + rx * cos(theta);
double startY = y0 - ry * sin(theta);  // sign because Y grows to down

double thetaEnd = (startAngle + spanAngle) * M_PI / 180.0; 
double endX = x0 + rx * cos(thetaEnd);
double endY = y0 - ry * sin(thetaEnd);

We can restrict ellipses to circles, ellipses are too difficult, especially ellipses can be rotated if rx=ry=r sagitta = r - sqrt(r² – (chordLength/2)²) where chordLength = sqrt((endX-startX)²+(endY-startY)²)

Now, we have start and end point and sagitta, how to compute enclosing box (that is radius and center) and angle arc start and span?

edit retag flag offensive close merge delete

Comments

2

Is this question related to sagemath in any manner? If yes, please provide code making the first steps...

dan_fulea gravatar imagedan_fulea ( 2023-07-29 17:57:35 +0200 )edit