/************************************************************************ * * * File: point3v.h * * * * Author: Robb T. Koether * * * * Date: Sep 9, 2003 * * * * Purpose: This file contains the definition of the Point3v class * * * ************************************************************************/ #ifndef POINT3V_H #define POINT3V_H // Header files #include #include #include "vector3v.h" using namespace std; class Vector3v; /************************************************************************ * * * The definition of the Point3v class * * * ************************************************************************/ class Point3v { // Public member functions public: // Constructors Point3v() {coord[0] = 0.0; coord[1] = 0.0; coord[2] = 0.0; coord[3] = 1.0;} Point3v(const Point3v& p) { coord[0] = p.coord[0]; coord[1] = p.coord[1]; coord[2] = p.coord[2]; coord[3] = p.coord[3]; } Point3v(float x, float y, float z) {coord[0] = x; coord[1] = y; coord[2] = z; coord[3] = 1.0;} // Inspectors float x() const {return coord[0];} float y() const {return coord[1];} float z() const {return coord[2];} float* v() const {return (float*)coord;} // Mutators void x(float x) {coord[0] = x;} void y(float y) {coord[1] = y;} void z(float z) {coord[2] = z;} void set(float x, float y, float z) {coord[0] = x; coord[1] = y; coord[2] = z;} void Output(ostream& out) const { out << "(" << coord[0] << ", " << coord[1] << ", " << coord[2] << ")"; } // Other functions Vector3v subtractP(const Point3v& p) const; Point3v addV(const Vector3v& v) const; Point3v subtractV(const Vector3v& v) const; bool equal(const Point3v& p) const; // Public data members public: float coord[4]; }; // Operators ostream& operator<<(ostream& out, const Point3v& p); Point3v operator+(const Point3v& p, const Vector3v& v); Point3v operator-(const Point3v& p, const Vector3v& v); Vector3v operator-(const Point3v& p, const Point3v& q); bool operator==(const Point3v& p, const Point3v& q); #endif