-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrPointi.h
80 lines (73 loc) · 2.23 KB
/
rPointi.h
1
#ifndef rPointihh#define rPointihh//#include <malloc.h>//#include "utils.h"#include "rPoint.h"#include <stdlib.h>#include <ostream>#include <iostream>class rPointi;/* * Class declarations */class rPointi{ friend std::ostream &operator << (std::ostream& os, rPointi& p) { os << "<" <<p.x<<" "<<p.y<<" "<<p.z<< ">"; return os; } /* used with cout */ protected: public: int x,y,z,*pt; rPointi () { x=y=z=0;} rPointi (int i,int j,int k) {x=i,y=j;z=k;pt=&x;} //~rPointi () { x=y=z=0;}; //void dout ();/* the display routine */ rPointi& operator=(rPointi p) { x=p.x; y=p.y; z=p.z; return (*this);} int operator==(rPointi ); int operator!=(rPointi ); int operator<=(rPointi ); int operator>=(rPointi ); int operator<(rPointi ); int operator>(rPointi ); int length () { return (x+y+z); } void neg () { x = -x; y = -y; z = -z; } void negate () { x = -x; y = -y; z = -z; } int& operator[] (int n) { return *(pt+n); } rPointi& operator+=(rPointi); rPointi& operator+(int); rPointi& operator+=(int); rPointi& operator-=(rPointi); rPointi& operator-(int); rPointi& operator-=(int); rPointi& operator*=(rPointi); rPointi& operator*(int); rPointi& operator*=(int); rPointi& operator/=(rPointi); rPointi& operator/(int); rPointi& operator/=(int); operator rPoint () { rPoint p((double)x,(double)y,(double)z); return p; } int iszero () { return x==0.0 && y==0.0 && z==0.0; } void set(int mx,int my,int mz) { x = mx; y = my; z = mz; } friend rPointi operator+(rPointi ,rPointi ); friend rPointi operator-(rPointi ,rPointi ); void randomcolor () {// set (((int)(frand()*255)+128) % 255,((int)(frand()*255)+128) % 255,((int)(frand()*255)+128) % 255); } void percentcolor (double x,double y,double z) { set (((int)(x*255)+64) % 255,((int)(y*255)+64) % 255,((int)(z*255)+64) % 255); }/* friend rVector operator+(int ,rVector ); friend rVector operator+(rVector ,int ); friend rVector operator-(int ,rVector ); friend rVector operator-(rVector ,int );*/ friend rPoint operator*(rPoint p,rMatrix_3_3 &m); friend rPoint operator*(rMatrix_3_3 &m,rPoint p);};#endif