# Untitled

a guest
Mar 29th, 2020
624
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include <bits/stdc++.h>
2. using namespace std;
3.
4. #define rep(i, a, b) for(int i = a; i < (b); ++i)
5. #define trav(a, x) for(auto& a : x)
6. #define all(x) begin(x), end(x)
7. #define sz(x) (int)(x).size()
8. typedef long long ll;
9. typedef pair<int, int> pii;
10. typedef vector<int> vi;
11.
12. int Z;
13. template<class T> struct Point3D {
14.     typedef Point3D P;
15.     typedef const P& R;
16.     T x, y, z;
17.     explicit Point3D(T x=0, T y=0, T z=0) : x(x), y(y), z(z) {}
18.     bool operator<(R p) const {
19.         return tie(x, y, z) < tie(p.x, p.y, p.z); }
20.     bool operator==(R p) const {
21.         return tie(x, y, z) == tie(p.x, p.y, p.z); }
22.     P operator+(R p) const { return P(x+p.x, y+p.y, z+p.z); }
23.     P operator-(R p) const { return P(x-p.x, y-p.y, z-p.z); }
24.     P operator*(T d) const { return P(x*d, y*d, z*d); }
25.     P operator/(T d) const { return P(x/d, y/d, z/d); }
26.     T dot(R p) const { return x*p.x + y*p.y + z*p.z; }
27.     P cross(R p) const {
28.         return P(y*p.z - z*p.y, z*p.x - x*p.z, x*p.y - y*p.x);
29.     }
30.     T dist2() const { return x*x + y*y + z*z; }
31.     double dist() const { return sqrt((double)dist2()); }
32.     //Azimuthal angle (longitude) to x-axis in interval [-pi, pi]
33.     double phi() const { return atan2(y, x); }
34.     //Zenith angle (latitude) to the z-axis in interval [0, pi]
35.     double theta() const { return atan2(sqrt(x*x+y*y),z); }
36.     P unit() const { return *this/(T)dist(); } //makes dist()=1
37.     //returns unit vector normal to *this and p
38.     P normal(P p) const { return cross(p).unit(); }
39.     //returns point rotated 'angle' radians ccw around axis
40.     P rotate(double angle, P axis) const {
41.         double s = sin(angle), c = cos(angle); P u = axis.unit();
42.         return u*dot(u)*(1-c) + (*this)*c - cross(u)*s;
43.     }
44. };
45. typedef Point3D<double> P;
46. P A,B,C;
47. double R,d;
48. void solve(){
49.     cin>>A.x>>A.y>>A.z>>B.x>>B.y>>B.z>>R>>C.x>>C.y>>C.z>>d;
50.     P D = B-A;
51.     double st = (-d-A.dot(C))/D.unit().dot(C);
52.     double cu = acos(abs(D.unit().dot(C.unit())));
53.     double deg= asin(R/(B-A).dist());
54.     double b = abs((st/abs(tan(cu)+1/tan(deg))+st/abs(1/tan(deg)-tan(cu)))/cos(cu)/2);
55.     double fa = st*tan(deg),dis = b-abs(st/abs(tan(cu)+1/tan(deg))/cos(cu));
56.     double a = fa*b/sqrt(abs(b*b-dis*dis));
57.     cout<<a*b*acos(-1)<<endl;
58. }
59.
60. int main() {
61.     cin>>Z;
62.     cout<<setprecision(15)<<fixed;
63.     while(Z--){
64.         solve();
65.     }
66.     return 0;
67. }