I am in need of determining the radius at the corners of a rectangle based on some given data points along the curve. The image below provides a visual representation:
https://i.stack.imgur.com/7FHq0.png
How can I calculate the radius using these specific coordinates? Below is the dataset available for calculation:
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
The data has been organized into respective corners (where top corners are curved and bottom ones 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 }
]
}
My goal is to determine the radius at the top left and right corners. I have come across the formula for calculating curvature radii, but I am unsure how to implement it as my mathematical background is limited. :/
For this task, I am utilizing JavaScript; however, understanding the algorithm itself is more crucial than the programming language used.