Added magnitude method to vector class
parent
5c02e61ec1
commit
6ca0b50a51
4
Eci.cpp
4
Eci.cpp
|
@ -21,12 +21,12 @@ Eci::Eci(const Julian &date, const CoordGeodetic &geo)
|
||||||
position_.SetY(achcp * sin(theta));
|
position_.SetY(achcp * sin(theta));
|
||||||
|
|
||||||
position_.SetZ((Globals::XKMPER() * s + altitude) * sin(latitude));
|
position_.SetZ((Globals::XKMPER() * s + altitude) * sin(latitude));
|
||||||
position_.SetW(sqrt(pow(position_.GetX(), 2.0) + pow(position_.GetY(), 2.0) + pow(position_.GetZ(), 2.0)));
|
position_.SetW(position_.GetMagnitude());
|
||||||
|
|
||||||
velocity_.SetX(-mfactor * position_.GetY());
|
velocity_.SetX(-mfactor * position_.GetY());
|
||||||
velocity_.SetY(mfactor * position_.GetX());
|
velocity_.SetY(mfactor * position_.GetX());
|
||||||
velocity_.SetZ(0.0);
|
velocity_.SetZ(0.0);
|
||||||
velocity_.SetW(sqrt(pow(velocity_.GetX(), 2.0) + pow(velocity_.GetY(), 2.0)));
|
velocity_.SetW(velocity_.GetMagnitude());
|
||||||
}
|
}
|
||||||
|
|
||||||
Eci::Eci(const Julian &date, const Vector &position, const Vector &velocity)
|
Eci::Eci(const Julian &date, const Vector &position, const Vector &velocity)
|
||||||
|
|
|
@ -1 +1,5 @@
|
||||||
#include "Vector.h"
|
#include "Vector.h"
|
||||||
|
|
||||||
|
double Vector::GetMagnitude() const {
|
||||||
|
return sqrt(x_ * x_ + y_ * y_ + z_ * z_);
|
||||||
|
}
|
||||||
|
|
4
Vector.h
4
Vector.h
|
@ -1,6 +1,8 @@
|
||||||
#ifndef VECTOR_H_
|
#ifndef VECTOR_H_
|
||||||
#define VECTOR_H_
|
#define VECTOR_H_
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
class Vector {
|
class Vector {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -43,6 +45,8 @@ public:
|
||||||
return w_;
|
return w_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double GetMagnitude() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
double x_;
|
double x_;
|
||||||
double y_;
|
double y_;
|
||||||
|
|
Loading…
Reference in New Issue