Find the arc point of the midpoint given by the start, end, and center (circle) point

I am looking for some help finding an arc point. I have a start and end point, the center of the circle and the radius. I searched everywhere on the Internet and cannot find an answer that I can convert to code anywhere. If anyone has any ideas, let me know. The next picture is what I'm trying to find (suppose the center of the circle is already found).

Find Midpoint?

+5
source share
3 answers

Atan2 () of the mean of x1, x2 and the mean of y1, y2 gives you the angle to the midpoint. Thus, the midpoint on the arc is defined as:

double c=Math.Atan2(y1+y2, x1+x2);
double x_mid=R*Math.Cos(c);
double y_mid=R*Math.Sin(c);

Note that I removed the 1/2 factor (for the average value) from both arguments in Atan2, since this does not change the angle.

Update:, . , .

+1

.

(x1, y1), (x2, y2)

. .

(r, theta1), (r, theta2)

.

(r, (theta2 + theta1) / 2)

.

EDIT: - :

def Point CenterOfArc(Point start, end, center)
    let (x1, y1) = (start.x - center.x, start.y - center.y)
    let (y1, y2) = (end.x   - center.x, end.y   - center.y)

    let (r1, theta1) = (sqrt(x1^2 + y1^2), atan(y1/x1))
    let (r2, theta2) = (sqrt(x2^2 + y2^2), atan(y2/x2))
    if (theta1 > theta2) theta2 += 2 * pi

    let (r, theta) = ((r1 + r2) / 2, (theta1 + theta2) / 2) // averaging in case of rounding error

    let (x, y) = (r * cos(theta), r * sin(theta))

    return (x + center.x, y + center.y)
end

EDIT2: , , theta2 > theta1, .

EDIT3: , tan<sup>-1</sup>(y/x) , atan2(y, x), atan(y/x). atan2 , x = 0 .

0

Although this function returns an approximate point, it is useful for practical purposes. I just thought about it and it works great.

Prerequisites:
An arc center (0, 0) is assumed here, although this could be changed to work with the center point parameter
- you must know the angle at which the arc starts (e.g. 270)
- you must know the measurement of the angle of the arc (e.g. 90 degrees)

The code below is written in Objective-C:

#define   DEGREES_TO_RADIANS(degrees)  ((M_PI * degrees)/ 180)
- (CGPoint)getApproximateMidPointForArcWithStartAngle:(CGFloat)startAngle andDegrees:(CGFloat)degrees {

CGFloat midPointDegrees = fmodf(startAngle + degrees / 2, 360);
CGFloat midStartAngle = midPointDegrees - .1f;
CGFloat midEndAngle = midPointDegrees + .1f;

UIBezierPath *midPointPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(0, 0) radius:self.radius startAngle:DEGREES_TO_RADIANS(midStartAngle) endAngle:DEGREES_TO_RADIANS(midEndAngle) clockwise:YES];

CGRect midPointPathFrame = CGPathGetPathBoundingBox(midPointPath.CGPath);
CGPoint approximateMidPointCenter = CGPointMake(CGRectGetMidX(midPointPathFrame), CGRectGetMidY(midPointPathFrame));
return approximateMidPointCenter;
}
0
source