I need to calculate the radius of a corner of a rectangle and the data I have to figure it out with is some points along the curve. Below is picture to illustrate:
How do I calculate the radius from these three coordinates? Here is the data I have to work with:
middleY: 321.4
middleX: 272.625
top: 301
bottom: 341.8
left: 193
right: 352.25
0: x: 331.85, y: 301
1: x: 346.25, y: 306.95
2: x: 352.25, y: 321.4
3: x: 352.25, y: 341.8
4: x: 213.4, y: 301
5: x: 193, y: 341.8
6: x: 193, y: 321.4
7: x: 198.95, y: 306.95
I have sorted it out to corners (top corners are curved and bottom are not):
{
"topLeft": [
{ "x": 213.4, "y": 301 },
{ "x": 193,"y": 321.4 },
{ "x": 198.95,"y": 306.95 }
],
"topRight": [
{ "x": 331.85,"y": 301 },
{ "x": 346.25,"y": 306.95 },
{ "x": 352.25,"y": 321.4 }
],
"bottomLeft": [
{ "x": 193,"y": 341.8 }
],
"bottomRight": [
{ "x": 352.25,"y": 341.8 }
]
}
What I want to do is calculate the radius of the top left and right corners. I have found the radius of curvature formula, but I have no idea what to do with it, since I didn't take enough math to get there. :/
I am using Javascript, by the way, but I don't think that matters as much as just understanding how to use the algorithm.
rx = |x1-x0|; ry = |y1-y0|;
for circular arcsrx=ry
otherwise elliptic ones are used ... for rotated ones you can use this Circular approximation of polygon (or its part) or un-rotate first