-
Notifications
You must be signed in to change notification settings - Fork 0
/
rPoint.cpp
262 lines (247 loc) · 4.3 KB
/
rPoint.cpp
1
//#include <iostream.h>#include <math.h>#include "rPoint2D.h"#include "rPoint.h"#include "rPointi.h"#include "rVector.h"#include "rLatLon.h"#include "rMatrix.h"/* * Class declarations */rPoint::rPoint () { x=y=z=0.0;//pt=&x;}/*rPoint::rPoint (rPoint &p){ set (p);}*/rPoint::rPoint (rPoint2D p){ set (p);}rPoint::rPoint (rVector p){ set (p);}void rPoint::set (rPoint2D p) { /* y is equivalent to lattitude and x is longitutde. */ x = sin (PI/2.0-p.y) * cos (p.x); y = sin (PI/2.0-p.y) * sin (p.x); z = cos (PI/2.0-p.y);}void rPoint::set (rVector p) { set (p.x,p.y,p.z);}rPoint::rPoint (double i,double j,double k) { set (i,j,k);//pt=&x;}/*rPoint &rPoint::operator=(rVector &p){ set (p.x,p.y,p.z); return (*this);}*/rPoint &rPoint::operator=(rPoint p){ set (p.x,p.y,p.z); return (*this);}rPoint &rPoint::operator=(rPoint2D p){ set (p); return *this;}/*rPoint::operator rVector () { rVector v; v = *this; return v;}*/rPoint::operator rPoint2D () { rPoint2D v; v = *this; return v;}/*rPoint::operator rLatLon () { rLatLon v; v = (rLatLon)*this; return v;}*/int rPoint::operator==(rPoint p){ return (x == p.x && y == p.y && z == p.z);}int rPoint::operator<=(rPoint p){ return (x <= p.x && y <= p.y && z <= p.z);}int rPoint::operator>=(rPoint p){ return (x >= p.x && y >= p.y && z >= p.z);}int rPoint::operator>(rPoint p){ return (x > p.x && y > p.y && z > p.z);}int rPoint::operator<(rPoint p){ return (x < p.x && y < p.y && z < p.z);}/*void rPoint::dout (){ cout <<" x:"<< x <<" y:"<<y<<" z:"<<z << "\n";}*/rPoint& rPoint::operator+=(rPoint b){ x += b.x; y += b.y; z += b.z; return (*this);}rPoint& rPoint::operator+(double s){ x += s; y += s; z += s; return (*this);}rPoint& rPoint::operator+=(double s){ x += s; y += s; z += s; return (*this);}/* Subtract two rPoints. */rPoint& rPoint::operator-=(rPoint b){ x -= b.x; y -= b.y; z -= b.z; return (*this);}rPoint& rPoint::operator-(double s){ x -= s; y -= s; z -= s; return (*this);}rPoint& rPoint::operator-=(double s){ x -= s; y -= s; z -= s; return (*this);}/* Multiply two rPoints. */rPoint operator*(rPoint p,rMatrix_3_3 &m) { rPoint r; r.x = p.x*m.mCol1.x + p.y*m.mCol1.y + p.z*m.mCol1.z; r.y = p.x*m.mCol2.x + p.y*m.mCol2.y + p.z*m.mCol2.z; r.z = p.x*m.mCol3.x + p.y*m.mCol3.y + p.z*m.mCol3.z; return r;}rPoint operator*(rMatrix_3_3 &m,rPoint p) { rPoint r; r.x = p.x*m.mCol1.x + p.y*m.mCol1.y + p.z*m.mCol1.z; r.y = p.x*m.mCol2.x + p.y*m.mCol2.y + p.z*m.mCol2.z; r.z = p.x*m.mCol3.x + p.y*m.mCol3.y + p.z*m.mCol3.z; return r;}rPoint operator*(rPoint a, rPoint b){ rPoint c; c.x = a.x * b.x; c.y = a.y * b.y; c.z = a.z * b.z; return (c);}rPoint& rPoint::operator*=(rPoint b){ x *= b.x; y *= b.y; z *= b.z; return (*this);}rPoint& rPoint::operator*(double s){ x *= s; y *= s; z *= s; return (*this);}rPoint& rPoint::operator*=(double s){ x *= s; y *= s; z *= s; return (*this);}rPoint &rPoint::operator*=(rMatrix_3_3 &m) { x=x*m.mCol1.x + y*m.mCol1.y + z*m.mCol1.z; y=x*m.mCol2.x + y*m.mCol2.y + z*m.mCol2.z; z=x*m.mCol3.x + y*m.mCol3.y + z*m.mCol3.z; return (*this);}/* Divide two rPoints. */rPoint operator/(rPoint a, rPoint b){ rPoint c; c.x = a.x / b.x; c.y = a.y / b.y; c.z = a.z / b.z; return (c);}rPoint& rPoint::operator/=(rPoint b){ x /= b.x; y /= b.y; z /= b.z; return (*this);}rPoint& rPoint::operator/(double s){ x /= s; y /= s; z /= s; return (*this);}rPoint& rPoint::operator/=(double s){ x /= s; y /= s; z /= s; return (*this);}/* Add rPoints by scalars. */rPoint operator+(double a,rPoint b){ rPoint c(a+b.x,a+b.y,a+b.z); return c;}rPoint operator+(rPoint b,double a){ rPoint c(a+b.x,a+b.y,a+b.z); return c;}/* Subtract rPoints by scalars. */rPoint operator-(double a,rPoint b){ rPoint c(a-b.x,a-b.y,a-b.z); return c;}rPoint operator-(rPoint b,double a){ rPoint c(a-b.x,a-b.y,a-b.z); return c;}/* Add two rPoints */rPoint operator+(rPoint a,rPoint b){ rPoint c(a.x+b.x,a.y+b.y,a.z+b.z); return c;}/* Subtract two rPoints. */rPoint operator-(rPoint a,rPoint b){ rPoint c(a.x-b.x,a.y-b.y,a.z-b.z); return c;}