给出两个点,找到过这两个点的等角螺线,并求出中间的螺线长
$c = \frac{b}{a}$
$p = a \times c^{\frac{\theta}{angle}}$
对弧线积分
#include <bits/stdc++.h> using namespace std; long double eps = 1e-8; struct Point { long double x, y; Point(long double _x = 0, long double _y = 0) { x = _x; y = _y; } Point operator - (const Point &b) { return Point(x - b.x, y - b.y); } }a[4]; long double Dot(Point &a, Point b) { return a.x * b.x + a.y * b.y; } long double len(Point &a) { return sqrt(Dot(a, a)); } int cmp(long double x) { if (fabs(x) < eps) return 0; return eps > 0? 1: -1; } int main() { for (int i = 1; i <= 3; ++ i) cin >> a[i].x >> a[i].y; a[1] = a[1] - a[3]; a[2] = a[2] - a[3]; long double tmp = Dot(a[1], a[2]); long double len1 = len(a[1]), len2 = len(a[2]); if (cmp(tmp - len1 * len2) == 0) { long double ans = fabs(len1 - len2); cout << fixed << setprecision(12) << ans << ‘\n‘; return 0; } auto sqr = [&](long double x) -> long double { return x * x; }; long double ang = acos(tmp / len1 / len2); long double ans = ang * len1; if (cmp(len1 - len2)) { long double C = len2 / len1; ans = (C - 1) / log(C) * ans; ans = ans * sqrt(1 + sqr(log(C) / ang)); } cout << fixed << setprecision(12) << ans << ‘\n‘; }
原文地址:https://www.cnblogs.com/tempestT/p/10673163.html
时间: 2024-10-29 00:57:50