在C ++中找到圆环中直径的另一端坐标

假设在圆的圆周上有中心坐标和一个坐标点。我们必须在周界上找到另一个点。考虑中心点是(p,q),一个给定点是(a,b)。我们必须找到点(x,y)。众所周知,中心是直径的中点。所以我们可以这样写-

(p,q)=(a + x / 2,b + y / 2)

或者由此,(x,y)可以表示为-

x = 2p-a,y = 2q-b

示例

#include<iostream>
using namespace std;
int getCylinderPerimeter(int d, int h) {
   return (2*d) + (2*h);
}
int main() {
   int diameter = 5, height = 10;
   cout << "Perimeter: " << getCylinderPerimeter(diameter, height) << " units";
}

输出结果

Perimeter: 30 units