comp-library

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

View the Project on GitHub luzhiled1333/comp-library

:heavy_check_mark: 円 (整数幾何)
(src/geometry/Z2/class/circle.hpp)

中心座標 $\boldsymbol{o} \in {\mathbb{Z}}^2$、半径 $r \in {\mathbb{Z}}_{\geq 0}$ の円を表す。

コンストラクタ

(1) Z2::Circle()
(2) Z2::Circle(Z2::Point o, Z2 r)
  1. Z2::Circle のデフォルトコンストラクタ。原点を中心とする半径 $0$ の円が格納される。
  2. 中心座標 o、半径 r の円が格納される。

制約

中心座標

Z2::Point center() const

円の中心座標を返す。

半径

Z r() const

円の半径を返す。

エイリアス

その他、std::vector< Circle<Z> > のエイリアスとして Circles<Z> が定義されている。

Depends on

Required by

Verified with

Code

#pragma once

#include "src/geometry/Z2/class/point.hpp"

#include <cassert>

namespace luz::Z2 {

  template < typename Z >
  class Circle {

    Point< Z > o_;
    Z r_;

   public:
    Circle(): o_(0, 0), r_(0) {}

    Circle(Point< Z > o, Z r): o_(o), r_(r) {
      assert(r >= 0);
    }

    Point< Z > center() const {
      return o_;
    }

    Z r() const {
      return r_;
    }
  };

  template < typename Z >
  using Circles = std::vector< Circle< Z > >;

} // namespace luz::Z2
#line 2 "src/geometry/Z2/class/circle.hpp"

#line 2 "src/geometry/Z2/class/point.hpp"

#line 2 "src/geometry/Z2/class/vector.hpp"

#include <vector>

namespace luz::Z2 {

  template < typename Z >
  class Vector {

    Z x_, y_;

   public:
    Vector(): x_(0), y_(0) {}
    Vector(Z x, Z y): x_(x), y_(y) {}

    Z x() const {
      return x_;
    }

    Z y() const {
      return y_;
    }

    bool operator==(const Vector &v) const {
      return x_ == v.x_ and y_ == v.y_;
    }

    bool operator!=(const Vector &v) const {
      return x_ != v.x_ or y_ != v.y_;
    }

    Vector &operator+=(const Vector &v) {
      x_ += v.x_;
      y_ += v.y_;
      return *this;
    }
    Vector &operator-=(const Vector &v) {
      x_ -= v.x_;
      y_ -= v.y_;
      return *this;
    }

    Vector operator+(const Vector &v) const {
      return Vector(*this) += v;
    }
    Vector operator-(const Vector &v) const {
      return Vector(*this) -= v;
    }

    Vector operator+() const {
      return *this;
    }
    Vector operator-() const {
      return Vector() - *this;
    }
  };

  template < typename Z >
  using Vectors = std::vector< Vector< Z > >;

} // namespace luz::Z2
#line 4 "src/geometry/Z2/class/point.hpp"

#line 6 "src/geometry/Z2/class/point.hpp"

namespace luz::Z2 {

  template < typename Z >
  using Point = Vector< Z >;

  template < typename Z >
  using Points = std::vector< Point< Z > >;

} // namespace luz::Z2
#line 4 "src/geometry/Z2/class/circle.hpp"

#include <cassert>

namespace luz::Z2 {

  template < typename Z >
  class Circle {

    Point< Z > o_;
    Z r_;

   public:
    Circle(): o_(0, 0), r_(0) {}

    Circle(Point< Z > o, Z r): o_(o), r_(r) {
      assert(r >= 0);
    }

    Point< Z > center() const {
      return o_;
    }

    Z r() const {
      return r_;
    }
  };

  template < typename Z >
  using Circles = std::vector< Circle< Z > >;

} // namespace luz::Z2
Back to top page