point2d.cpp
资源名称:package.rar [点击查看]
上传用户:chinasdcnc
上传日期:2022-07-02
资源大小:2702k
文件大小:1k
源码类别:
分形几何
开发平台:
Visual C++
- //
- // Delaunay Triangulation
- //
- // Homework of CG lesson (Fall 2009) in Tsinghua University.
- // All rights reserved.
- //
- // temp include, delete later if necessary
- #include "stdafx.h"
- #include "point2d.h"
- // User headers
- #include "base.h"
- Point2d::Point2d(void)
- : x(0), y(0)
- {
- }
- Point2d::Point2d(double tx, double ty)
- : x(tx), y(ty)
- {
- }
- Point2d::Point2d(const Point2d& p)
- {
- x = p.x;
- y = p.y;
- }
- Point2d Point2d::operator+(const Vector2d& v) const
- {
- return Point2d(x + v.x, y + v.y);
- }
- Vector2d Point2d::operator-(const Point2d& p) const
- {
- return Vector2d(x - p.x, y - p.y);
- }
- bool Point2d::operator==(const Point2d& p) const
- {
- if (fabs(x - p.x) >= TOLERANCE || fabs(y - p.y) >= TOLERANCE)
- return false;
- return true;
- }
- bool Point2d::operator<(const Point2d& p) const
- {
- if(x < p.x)
- {
- return true;
- }
- else
- {
- if(x > p.x)
- return false;
- else
- return (y < p.y);
- }
- }