vector2d.h
资源名称:package.rar [点击查看]
上传用户:chinasdcnc
上传日期:2022-07-02
资源大小:2702k
文件大小:2k
源码类别:
分形几何
开发平台:
Visual C++
- //
- // Delaunay Triangulation
- //
- // Homework of CG lesson (Fall 2009) in Tsinghua University.
- // All rights reserved.
- //
- #pragma once
- /**
- * class for 2d vector.
- */
- class Vector2d
- {
- // public constructors & destructor
- public:
- /**
- * Sets all coordinate values to 0.0 by default.
- */
- Vector2d(void);
- /**
- * Sets x, y coordinate values with @c tx and @c ty.
- */
- Vector2d(double tx, double ty);
- /**
- * Copy constructor.
- */
- Vector2d(const Vector2d& vect);
- // public member functions
- public:
- /**
- * Gets the norm of vector.
- */
- double norm(void) const;
- /**
- * Returns the square norm of vector.
- */
- double squareNorm(void) const;
- /**
- * Normalizes self.
- * @return true if it is nonzero vector, or else @return false.
- */
- bool normalize(void);
- /**
- * Operator +.
- */
- Vector2d operator+(const Vector2d& vect) const;
- /**
- * Operator +=.
- */
- Vector2d& operator+=(const Vector2d& vect);
- /**
- * Operator -.
- */
- Vector2d operator-(const Vector2d& vect) const;
- /**
- * Operator -=.
- */
- Vector2d& operator-=(const Vector2d& vect);
- /**
- * Operator *.
- */
- Vector2d operator*(double c) const;
- /**
- * Operator *=.
- */
- Vector2d& operator*=(double c);
- /**
- * Returns the dot product of two <code>Vector2d</code>s.
- */
- double dot(const Vector2d& vect);
- // public data members
- public:
- double x;
- double y;
- };