comp-geometry

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

View the Project on GitHub Luzhiled/comp-geometry

:heavy_check_mark: src/real-geometry/operation/cross-product.hpp

Depends on

Required by

Verified with

Code

#pragma once

#include "src/real-geometry/class/vector.hpp"

namespace geometry {

  template< typename R >
  R cross_product(const vec2d<R> &a, const vec2d<R> &b) {
    return a.x() * b.y() - a.y() * b.x();
  }

}
#line 2 "src/real-geometry/operation/cross-product.hpp"

#line 2 "src/real-geometry/class/vector.hpp"

#include <complex>
#include <iostream>

namespace geometry {

  template< typename R >
  class vec2d : public std::complex< R > {
    using complex = std::complex< R >;

   public:
    using complex::complex;

    vec2d(const complex &c): complex::complex(c) {}

    const R x() const { return this->real(); }
    const R y() const { return this->imag(); }

    friend vec2d operator*(const vec2d &v, const R &k) {
      return vec2d(v.x() * k, v.y() * k);
    }

    friend vec2d operator*(const R &k, const vec2d &v) {
      return vec2d(v.x() * k, v.y() * k);
    }

    friend std::istream &operator>>(std::istream &is, vec2d &v) {
      R x, y;
      is >> x >> y;
      v = vec2d(x, y);
      return is;
    }
 
  };

}
#line 4 "src/real-geometry/operation/cross-product.hpp"

namespace geometry {

  template< typename R >
  R cross_product(const vec2d<R> &a, const vec2d<R> &b) {
    return a.x() * b.y() - a.y() * b.x();
  }

}
Back to top page