icpc_library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub ebi-fly13/icpc_library

:warning: geometry3D/ld/base_ld.hpp

Depends on

Required by

Code

#pragma once

#include "../../template/template.hpp"
#include "../base_arbitary.hpp"

namespace lib {

using vec = Vec<ld>;
const ld eps = 1e-7;

void ldout(int len = 20) { cout << fixed << setprecision(len); }

int sgn(ld a) { return (a < -eps) ? -1 : (a > eps) ? 1 : 0; }

ld dot(const vec &a, const vec &b){
    return a.x*b.x + a.y*b.y + a.z*b.z;
}

vec cross(const vec &a, const vec &b){
    return Vec(a.y*b.z-a.z*b.y, a.z*b.x-a.x*b.z, a.x*b.y-a.y*b.x);
}

ld norm(const vec &a){
    return a.x*a.x+a.y*a.y+a.z*a.z;
}

ld abs(const vec &a){
    return sqrtl(norm(a));
}


}  // namespace lib
#line 2 "geometry3D/ld/base_ld.hpp"

#line 2 "template/template.hpp"

#include <bits/stdc++.h>

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)
#define all(v) v.begin(), v.end()

using ll = long long;
using ld = long double;
using ull = unsigned long long;

template <typename T> bool chmin(T &a, const T &b) {
    if (a <= b) return false;
    a = b;
    return true;
}
template <typename T> bool chmax(T &a, const T &b) {
    if (a >= b) return false;
    a = b;
    return true;
}

namespace lib {

using namespace std;

}  // namespace lib

// using namespace lib;
#line 2 "geometry3D/base_arbitary.hpp"

#line 4 "geometry3D/base_arbitary.hpp"

namespace lib {

template<typename T>
struct Vec {
    T x, y, z;
    Vec (T _x = 0, T _y = 0, T _z = 0) : x(_x), y(_y), z(_z) {}
    Vec& operator*=(const T& a){
        x *= a;
        y *= a;
        z *= a;
        return *this;
    }
    Vec& operator/=(const T& a){
        x /= a;
        y /= a;
        z /= a;
        return *this;
    }
    Vec& operator+=(const Vec& rhs) {
        x += rhs.x;
        y += rhs.y;
        z += rhs.z;
        return *this;
    }
    Vec& operator-=(const Vec& rhs) {
        x -= rhs.x;
        y -= rhs.y;
        z -= rhs.z;
        return *this;
    }
    friend Vec operator+(const Vec& lhs, const Vec& rhs) {
        return Vec(lhs) += rhs;
    }
    friend Vec operator-(const Vec& lhs, const Vec& rhs) {
        return Vec(lhs) -= rhs;
    }
    friend Vec operator*(const Vec& lhs, const T& rhs) {
        return Vec(lhs) *= rhs;
    }
    friend Vec operator*(const T& rhs, const Vec& lhs) {
        return Vec(lhs) *= rhs;
    }
    friend Vec operator/(const Vec& lhs, const T& rhs) {
        return Vec(lhs) /= rhs;
    }
    friend std::ostream &operator<<(std::ostream &os,const Vec&r) {
        return os << "(" << r.x << "," << r.y << "," << r.z << ")"; 
    }
};

};
#line 5 "geometry3D/ld/base_ld.hpp"

namespace lib {

using vec = Vec<ld>;
const ld eps = 1e-7;

void ldout(int len = 20) { cout << fixed << setprecision(len); }

int sgn(ld a) { return (a < -eps) ? -1 : (a > eps) ? 1 : 0; }

ld dot(const vec &a, const vec &b){
    return a.x*b.x + a.y*b.y + a.z*b.z;
}

vec cross(const vec &a, const vec &b){
    return Vec(a.y*b.z-a.z*b.y, a.z*b.x-a.x*b.z, a.x*b.y-a.y*b.x);
}

ld norm(const vec &a){
    return a.x*a.x+a.y*a.y+a.z*a.z;
}

ld abs(const vec &a){
    return sqrtl(norm(a));
}


}  // namespace lib
Back to top page