[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gfx/libutil Vec23.hxx
From: |
Tuomas J. Lukka |
Subject: |
[Gzz-commits] gzz/gfx/libutil Vec23.hxx |
Date: |
Tue, 01 Oct 2002 06:32:49 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Tuomas J. Lukka <address@hidden> 02/10/01 06:32:49
Modified files:
gfx/libutil : Vec23.hxx
Log message:
Get rid of the point - vector distinction
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libutil/Vec23.hxx.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
Patches:
Index: gzz/gfx/libutil/Vec23.hxx
diff -c gzz/gfx/libutil/Vec23.hxx:1.10 gzz/gfx/libutil/Vec23.hxx:1.11
*** gzz/gfx/libutil/Vec23.hxx:1.10 Mon Sep 30 12:30:10 2002
--- gzz/gfx/libutil/Vec23.hxx Tue Oct 1 06:32:49 2002
***************
*** 27,91 ****
#include <math.h>
/** Simple vectors for 2D / 3D graphics.
- * XXX reorg (remove Point, Point3D, doc)
*/
namespace Vec23 {
using std::ostream;
template <class T>class Vector;
template <class T>class Vector3;
- template <class T>class Point3 ;
-
- template <class T>class Point {
- public:
- T x, y;
- Point() : x(0), y(0) { }
- Point(T x, T y) : x(x), y(y) { }
- Point(Point3<T> &p) : x(p.x), y(p.y) { }
- Vector<T> operator-(const Point &p) const { return Vector<T>(x - p.x, y
- p.y); }
- Point<T> operator+(const Vector<T> v)
- const { return Point<T>(x + v.x, y + v.y); }
- Point<T> operator-(const Vector<T> v)
- const { return Point<T>(x - v.x, y - v.y); }
- Point<T> &operator+=(const Vector<T> v) {
- x += v.x; y += v.y;
- return *this;
- }
- Point<T> &operator-=(const Vector<T> v) {
- x -= v.x; y -= v.y;
- return *this;
- }
- };
- template<class T> inline ostream& operator<<(ostream &o, const Point<T>
&p) {
- return o << "[point "<<p.x<<" "<<p.y<<"]";
- }
-
- template <class T>class Point3 {
- public:
- T x, y, z;
- Point3() : x(0), y(0), z(0) { }
- Point3(T x, T y, T z) : x(x), y(y), z(z) { }
- Point3(const Point<T> &p, T z = 0) : x(p.x), y(p.y), z(z) { }
- Point3(const Vector3<T> &v) : x(v.x), y(v.y), z(v.z) { }
- Vector3<T> operator-(const Point3 &p) const {
- return Vector3<T>(x - p.x, y - p.y, z - p.z); }
- Point3<T> operator+(const Vector3<T> v)
- const { return Point3<T>(x + v.x, y + v.y, z + v.z); }
- Point3<T> operator-(const Vector3<T> v)
- const { return Point3<T>(x - v.x, y - v.y, z - v.z); }
- Point3<T> &operator+=(const Vector3<T> v) {
- x += v.x; y += v.y; z += v.z;
- return *this;
- }
- Point3<T> &operator-=(const Vector3<T> v) {
- x -= v.x; y -= v.y; z -= v.z;
- return *this;
- }
- };
- template<class T> inline ostream& operator<<(ostream &o, const Point3<T>
&p) {
- return o << "[point "<<p.x<<" "<<p.y<<" "<<p.z<<"]";
- }
-
template <class T>class Vector {
public:
--- 27,38 ----
***************
*** 120,127 ****
T x, y, z;
Vector3() : x(0), y(0), z(0) { }
Vector3(T x, T y, T z) : x(x), y(y), z(z) { }
! Vector3(const Vector<T> &v, float z) : x(v.x), y(v.y), z(z) { }
! Vector3(const Point3<T> &v) : x(v.x), y(v.y), z(v.z) { }
Vector3 operator*(const double &s) const { return Vector3(s * x, s * y,
s * z); } ;
template<class U> const Vector3 &operator*=(const U &s) { x *= s; y *=
s; z *= s;
--- 67,73 ----
T x, y, z;
Vector3() : x(0), y(0), z(0) { }
Vector3(T x, T y, T z) : x(x), y(y), z(z) { }
! Vector3(const Vector<T> &v, float z = 0) : x(v.x), y(v.y), z(z) { }
Vector3 operator*(const double &s) const { return Vector3(s * x, s * y,
s * z); } ;
template<class U> const Vector3 &operator*=(const U &s) { x *= s; y *=
s; z *= s;
***************
*** 167,174 ****
T y0() { return y; }
T y1() { return y + h; }
! Point<T> ul() { return Point<T>(x, y); }
! Point<T> lr() { return Point<T>(x +w, y +h); }
};
template<class T>inline ostream& operator<<(ostream &o, const
Rectangle<T> &r) {
--- 113,120 ----
T y0() { return y; }
T y1() { return y + h; }
! Vector<T> ul() { return Vector<T>(x, y); }
! Vector<T> lr() { return Vector<T>(x +w, y +h); }
};
template<class T>inline ostream& operator<<(ostream &o, const
Rectangle<T> &r) {
***************
*** 176,183 ****
}
! typedef Point<float> Pt;
! typedef Point3<float> ZPt;
typedef Vector<float> Vec;
typedef Vector3<float> ZVec;
--- 122,129 ----
}
! typedef Vector<float> Pt;
! typedef Vector3<float> ZPt;
typedef Vector<float> Vec;
typedef Vector3<float> ZVec;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz/gfx/libutil Vec23.hxx,
Tuomas J. Lukka <=