/[libvob]/libvob/include/vob/Vec23.hxx
ViewVC logotype

Diff of /libvob/include/vob/Vec23.hxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by tjl, Fri May 16 15:13:10 2003 UTC revision 1.8 by tjl, Thu May 29 08:00:20 2003 UTC
# Line 92  namespace Vec23 { Line 92  namespace Vec23 {
92          Vector operator-(const Vector<T>&v) const { return Vector(x-v.x, y-v.y); }          Vector operator-(const Vector<T>&v) const { return Vector(x-v.x, y-v.y); }
93          /** Return a vector like this, but rotated 90 degrees clockwise.          /** Return a vector like this, but rotated 90 degrees clockwise.
94           */           */
95          Vector cw90() { return Vector(y, -x); }          Vector cw90() const { return Vector(y, -x); }
96          /** Return the length of this vector.          /** Return the length of this vector.
97           */           */
98          double length() { return hypot(x, y); }          double length() const { return hypot(x, y); }
99    
100          /** Dot this vector with another.          /** Dot this vector with another.
101           */           */
102          double dot(const Vector<T> &v) const { return x * v.x + y * v.y; }          double dot(const Vector<T> &v) const { return x * v.x + y * v.y; }
103    
104            /** Cross this 2D vector with another -
105             * gives the sine of the angle between the two,
106             * multiplied by the lengths.
107             * Useful for telling which side of a given vector you are.
108             */
109            double cross(const Vector<T> &v) const {
110                return x * v.y - y * v.x;
111            }
112    
113            double atan() const {
114                return atan2(x, y);
115            }
116      };      };
117    
118      /** Multiply vector by scalar.      /** Multiply vector by scalar.
# Line 301  namespace Vec23 { Line 314  namespace Vec23 {
314          HPoint2() {}          HPoint2() {}
315          HPoint2(T x, T y, T w) : x(x), y(y), w(w) { }          HPoint2(T x, T y, T w) : x(x), y(y), w(w) { }
316          HPoint2(ZPt p) : x(p.x), y(p.y), w(1) { }          HPoint2(ZPt p) : x(p.x), y(p.y), w(1) { }
317            HPoint2(Pt p) : x(p.x), y(p.y), w(1) { }
318    
319          HLine2<T> line(HPoint2 p) {          HLine2<T> line(HPoint2 p) {
320              T a, b, c;              T a, b, c;
# Line 354  namespace Vec23 { Line 368  namespace Vec23 {
368    
369      template<class T> T dot(Vector<T> a, Vector<T> b) { return a.dot(b); }      template<class T> T dot(Vector<T> a, Vector<T> b) { return a.dot(b); }
370    
371    
372        /** Give the direction vector for a given angle:
373         * (sin angle, cos angle).
374         */
375        inline Vec dirVec(float angle) {
376            return Vec(sin(angle), cos(angle));
377        }
378  }  }
379    
380  // Export some to Vob  // Export some to Vob
# Line 363  using Vec23::ZVec; Line 384  using Vec23::ZVec;
384  using Vec23::Pt;  using Vec23::Pt;
385  using Vec23::Vec;  using Vec23::Vec;
386  using Vec23::lerp;  using Vec23::lerp;
387    using Vec23::dirVec;
388  }  }
389  #endif  #endif

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26