Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define rep(i, a, b) for(int i = a; i < (b); ++i)
- #define trav(a, x) for(auto& a : x)
- #define all(x) begin(x), end(x)
- #define sz(x) (int)(x).size()
- typedef long long ll;
- typedef pair<int, int> pii;
- typedef vector<int> vi;
- int Z;
- template<class T> struct Point3D {
- typedef Point3D P;
- typedef const P& R;
- T x, y, z;
- explicit Point3D(T x=0, T y=0, T z=0) : x(x), y(y), z(z) {}
- bool operator<(R p) const {
- return tie(x, y, z) < tie(p.x, p.y, p.z); }
- bool operator==(R p) const {
- return tie(x, y, z) == tie(p.x, p.y, p.z); }
- P operator+(R p) const { return P(x+p.x, y+p.y, z+p.z); }
- P operator-(R p) const { return P(x-p.x, y-p.y, z-p.z); }
- P operator*(T d) const { return P(x*d, y*d, z*d); }
- P operator/(T d) const { return P(x/d, y/d, z/d); }
- T dot(R p) const { return x*p.x + y*p.y + z*p.z; }
- P cross(R p) const {
- return P(y*p.z - z*p.y, z*p.x - x*p.z, x*p.y - y*p.x);
- }
- T dist2() const { return x*x + y*y + z*z; }
- double dist() const { return sqrt((double)dist2()); }
- //Azimuthal angle (longitude) to x-axis in interval [-pi, pi]
- double phi() const { return atan2(y, x); }
- //Zenith angle (latitude) to the z-axis in interval [0, pi]
- double theta() const { return atan2(sqrt(x*x+y*y),z); }
- P unit() const { return *this/(T)dist(); } //makes dist()=1
- //returns unit vector normal to *this and p
- P normal(P p) const { return cross(p).unit(); }
- //returns point rotated 'angle' radians ccw around axis
- P rotate(double angle, P axis) const {
- double s = sin(angle), c = cos(angle); P u = axis.unit();
- return u*dot(u)*(1-c) + (*this)*c - cross(u)*s;
- }
- };
- typedef Point3D<double> P;
- P A,B,C;
- double R,d;
- void solve(){
- cin>>A.x>>A.y>>A.z>>B.x>>B.y>>B.z>>R>>C.x>>C.y>>C.z>>d;
- P D = B-A;
- double st = (-d-A.dot(C))/D.unit().dot(C);
- double cu = acos(abs(D.unit().dot(C.unit())));
- double deg= asin(R/(B-A).dist());
- double b = abs((st/abs(tan(cu)+1/tan(deg))+st/abs(1/tan(deg)-tan(cu)))/cos(cu)/2);
- double fa = st*tan(deg),dis = b-abs(st/abs(tan(cu)+1/tan(deg))/cos(cu));
- double a = fa*b/sqrt(abs(b*b-dis*dis));
- cout<<a*b*acos(-1)<<endl;
- }
- int main() {
- cin>>Z;
- cout<<setprecision(15)<<fixed;
- while(Z--){
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement