### Shift vector in x axis (Lorentz boost)

The rest of my code seem to work alright without the section on the "Lorentz boost". I'm not sure how I should approach this - I have to shift my 4-vector by "boosting it". Am I on the right track? - what should I return in the Boost function and how should I call it in the main? Thanks!

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148`` `````` #include #include using namespace std; //============================================================================= //Vector 3 //============================================================================= class Vector3 { // Friends //Prototypes overloading of << operator friend ostream & operator << (ostream &os, const Vector3 &v3); protected: double x; double y; double z; public: double xi; double yi; double zi; //Default constructor Vector3(){x=y=z=0;} //parameterised constructor Vector3(double xi, double yi, double zi) {x=xi; y=yi; z=zi;} //destructor ~Vector3(){}; //Acessor functions double Getx() const {return x;} double Gety() const {return y;} double Getz() const {return z;} //Scalar product function double scalar(Vector3 v3) const { double temp; temp=x*v3.Getx()+y*v3.Gety()+z*v3.Getz(); return temp; } //Overload () operator Vector3 operator() (double a, double b,double c) {return Vector3(a,b,c);} }; //Overload << operator for Vector3 ostream & operator<<(ostream & os, const Vector3 &v3) { os<<"("<
closed account (D80DSL3A)
I'm not sure what you mean by "boost". 4-vectors can be added just as 3-vectors can be, element by element. Perhaps your Boost function should return the sum of two Vector4 objects?
 ``1234`` ``````Vector4 Boost(Vector4 v4) const { return Vector4( a+v4.a, b+v4.b, c+v4.c, ct+v4.ct); }``````

It looks like you are applying a Lorentz transformation there currently, but to what?

I think your scalar() function calculation is wrong. Squared length is:
`temp=ct*v4.Getct()-( a*v4.Getx()+b*v4.Gety()+c*v4.Getz() );`

Other problems with your code. You have multiple duplication of data members (x,y,z:xi,yi,zi) in the Vector3 base class. What are xi,yi,zi for?
You then add another full set of coordinates in the Vector4 class (a,b,c,ct:ai,bi,cti) instead of using the xi,yi,zi inherited from Vector3.
I'm not sure what a call to getX() would get you. There is a version of getX() in each class, but they are non-virtual, differing only in their const-ness on the calling object. If the const (base) version gets called it will return the uninitialized value of x for a Vector4 object. Quite messy.
I've added this to the Lorentz transformation part. But i'm not sure what to return after this function. I need a vector to be returned but my function only returns a double, right?

 ``1234567891011121314`` `````` double LorentzTransformation(Vector4 v5) const { double Beta; double Gamma; double TRANSct; double TRANSx; double TRANSy; double TRANSz; double const LightSpeed=3e8; double const Velocity=2.8e8; Beta=Velocity/LightSpeed; Gamma=1/sqrt(1-Beta*Beta); TRANSct=Gamma*(v5.Getct()-Beta*v5.Getx()); TRANSx=Gamma*(v5.Getx()-Beta*v5.Getct()); TRANSy=v5.Gety(); TRANSz=v5.Getz(); } ``````
closed account (D80DSL3A)
OK. I think you're trying to apply the transformation to the calling Vector4 object (4-vector in unprimed frame) to produce the 4-vector in the primed (observers) frame of reference. The needed parameter would be the relative velocity between the reference frames. If the relative motion is along the x-axis only then a double would do.

It's been a lot of years since I studied relativity (college years), but here's my next guess at what you're looking for:
 ``123456789101112131415`` ``````// transform applied using the calling Vector4 object (this). Vector4 LorentzTransformation(double v) const// v is relative velocity along the x-axis. { const double LightSpeed=3e8;// defining constant double Beta = v/LightSpeed; double Gamma = 1/sqrt(1-Beta*Beta); // apply transformation and return result vPrime Vector4 vPrime; vPrime.ct = Gamma*( Getct()-Beta*Getx() ); vPrime.a = Gamma*( Getx()-Beta*Getct() ); vPrime.b = Gety(); vPrime.c = Getz(); return vPrime; }``````

 ``12345`` `````` double a; double v; a=v4.LorentzTransformation( v); v=1.2; cout<<"Lorentz transformation of Vector 5:"<