You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.0 KiB
45 lines
1.0 KiB
#ifndef POINT_HPP
|
|
#define POINT_HPP
|
|
|
|
#include "vector3.hpp"
|
|
#include <cstdint>
|
|
#define M_PI 3.1415
|
|
|
|
class Point {
|
|
private:
|
|
int64_t x_, y_, z_;
|
|
|
|
public:
|
|
Point(int64_t x = 0, int64_t y = 0, int64_t z = 0) : x_(x), y_(y), z_(z) {}
|
|
|
|
int64_t x() const { return x_; }
|
|
int64_t y() const { return y_; }
|
|
int64_t z() const { return z_; }
|
|
|
|
Point operator+(const Point& p) const;
|
|
Point operator-(const Point& p) const;
|
|
|
|
bool operator==(const Point& p) const;
|
|
bool operator!=(const Point& p) const;
|
|
|
|
// ת»»
|
|
Vector3 toVector3() const;
|
|
static Point fromVector3(const Vector3& v);
|
|
|
|
friend std::ostream& operator<<(std::ostream& os, const Point& p);
|
|
};
|
|
|
|
// Hashº¯Êý
|
|
namespace std {
|
|
template<>
|
|
struct hash<Point> {
|
|
size_t operator()(const Point& p) const {
|
|
size_t h1 = std::hash<int64_t>()(p.x());
|
|
size_t h2 = std::hash<int64_t>()(p.y());
|
|
size_t h3 = std::hash<int64_t>()(p.z());
|
|
return h1 ^ (h2 << 1) ^ (h3 << 2);
|
|
}
|
|
};
|
|
}
|
|
|
|
#endif
|