//------------------------------------------------------------------------------ bool Periapsis::Evaluate() { if (mOrigin == NULL) OrbitData::InitializeRefObjects(); Rvector6 cartState = OrbitData::GetRelativeCartState(mOrigin); //MessageInterface::ShowMessage // (wxT("===> Periapsis::Evaluate() mOrigin=%s, cartState=%s\n"), // mOrigin->GetName().c_str(), cartState.ToString().c_str()); if (cartState == Rvector6::RVECTOR6_UNDEFINED) return false; // compute position and velocity unit vectors Rvector3 pos = Rvector3(cartState[0], cartState[1], cartState[2]); Rvector3 vel = Rvector3(cartState[3], cartState[4], cartState[5]); Rvector3 R = pos.GetUnitVector(); Rvector3 V = vel.GetUnitVector(); // compute cos(90 - beta) as the dot product of the R and V vectors // Real rdotv = R*V; // mRealValue = rdotv; mRealValue = R*V; // Changed to use IsEqual() (LOJ: 2010.02.02) //if (mRealValue == 0.0) if (GmatMathUtil::IsEqual(mRealValue, 0.0)) mRealValue = 1.0e-40; return true; }
//------------------------------------------------------------------------------ bool Apoapsis::Evaluate() { if (mOrigin == NULL) OrbitData::InitializeRefObjects(); Rvector6 cartState = OrbitData::GetRelativeCartState(mOrigin); if (cartState == Rvector6::RVECTOR6_UNDEFINED) return false; // compute position and velocity unit vectors Rvector3 pos = Rvector3(cartState[0], cartState[1], cartState[2]); Rvector3 vel = Rvector3(cartState[3], cartState[4], cartState[5]); Rvector3 R = pos.GetUnitVector(); Rvector3 V = vel.GetUnitVector(); // compute cos(90 - beta) as the dot product of the R and V vectors Real rdotv = R*V; mRealValue = rdotv; if (mRealValue == 0.0) mRealValue = -1.0e-40; //MessageInterface::ShowMessage(wxT("Apoapsis::Evaluate() r=%f,%f,%f, v=%f,%f,%f, r.v=%f\n"), // R[0], R[1], R[2], V[0], V[1], V[2], rdotv); return true; }
//-------------------------------------------------------------------- void SurfaceMesh::RotateBody (const Rmatrix33& ts, const Rvector3 baseoffset, const Rvector3 appendageoffset) // Rotates the spacecraft vector valeus { for (int ip=0; ip<=GetVectorCount()-1; ++ip) { ZVectorCache& v = Vectors[ip]; Rvector3 aoffset = v.DoTranslate ? appendageoffset : Rvector3(0,0,0); Rvector3 boffset = v.DoTranslate ? baseoffset : Rvector3(0,0,0); Rvector3 result = ts * (v.WrtSpacecraft.ConvertToRvector3() - aoffset) + boffset; v.WrtSpacecraft = ZFloat3(result[0], result[1], result[2]); } }
//------------------------------------------------------------------------------ // <friend> // Rvector3 Cross(const Rvector3 &v1, const Rvector3 &v2) //------------------------------------------------------------------------------ Rvector3 Cross(const Rvector3 &v1, const Rvector3 &v2) { return Rvector3( v1.elementD[1]*v2.elementD[2] - v1.elementD[2]*v2.elementD[1], v1.elementD[2]*v2.elementD[0] - v1.elementD[0]*v2.elementD[2], v1.elementD[0]*v2.elementD[1] - v1.elementD[1]*v2.elementD[0]); }
//------------------------------------------------------------------------------ // Rvector3 operator/(Real s) const //------------------------------------------------------------------------------ Rvector3 Rvector3::operator/(Real s) const { if (GmatMathUtil::IsZero(s)) { throw RealUtilitiesExceptions::ArgumentError(); } return Rvector3(elementD[0]/s, elementD[1]/s, elementD[2]/s); }
//------------------------------------------------------------------------------ // Rvector3 GetUnitVector() const //------------------------------------------------------------------------------ Rvector3 Rvector3::GetUnitVector() const { Real mag = GetMagnitude(); if (GmatMathUtil::IsZero(mag)) throw ZeroVector(" from Rvector3::GetUnitVector()\n"); return Rvector3(elementD[0]/mag, elementD[1]/mag, elementD[2]/mag); }
//------------------------------------------------------------------------------ // <friend> // Rvector3 operator*(Real s, const Rvector3& v) //------------------------------------------------------------------------------ Rvector3 operator*(Real s, const Rvector3& v) { return Rvector3(s * v.elementD[0], s * v.elementD[1], s * v.elementD[2]); }
//------------------------------------------------------------------------------ // Rvector3 operator*(const Rmatrix33& m) const //------------------------------------------------------------------------------ Rvector3 Rvector3::operator*(const Rmatrix33& m) const { return Rvector3(elementD[0]*m(0,0) + elementD[1]*m(0,1) + elementD[2]*m(0,2), elementD[0]*m(1,0) + elementD[1]*m(1,1) + elementD[2]*m(1,2), elementD[0]*m(2,0) + elementD[1]*m(2,1) + elementD[2]*m(2,2)); }
//------------------------------------------------------------------------------ // Rvector3 operator*(Real s) const //------------------------------------------------------------------------------ Rvector3 Rvector3::operator*(Real s) const { return Rvector3(elementD[0]*s, elementD[1]*s, elementD[2]*s); }
//------------------------------------------------------------------------------ // const Rvector3 operator-(const Rvector3& v) const //------------------------------------------------------------------------------ Rvector3 Rvector3::operator-(const Rvector3& v) const { return Rvector3(elementD[0] - v.elementD[0], elementD[1] - v.elementD[1], elementD[2] - v.elementD[2]); }
//------------------------------------------------------------------------------ // Rvector3 operator+(const Rvector3& v) const //------------------------------------------------------------------------------ Rvector3 Rvector3::operator+(const Rvector3& v) const { return Rvector3(elementD[0] + v.elementD[0], elementD[1] + v.elementD[1], elementD[2] + v.elementD[2]); }
//------------------------------------------------------------------------------ // Rvector3 operator-() const // negation //------------------------------------------------------------------------------ Rvector3 Rvector3::operator-() const { return Rvector3(-elementD[0], -elementD[1], -elementD[2]); }