bool S3D::WriteVector( std::ostream& aFile, const SGVECTOR& aVector ) { double x, y, z; aVector.GetVector( x, y, z ); aFile.write( (char*)&x, sizeof(double) ); aFile.write( (char*)&y, sizeof(double) ); aFile.write( (char*)&z, sizeof(double) ); if( aFile.fail() ) return false; return true; }
// format vector data for VRML output void S3D::FormatVector( std::string& result, const SGVECTOR& aVector ) { double X, Y, Z; aVector.GetVector( X, Y, Z ); FormatFloat( result, X ); std::string tmp; FormatFloat( tmp, Y ); result.append( " " ); result.append( tmp ); FormatFloat( tmp, Z ); result.append( " " ); result.append( tmp ); return; }
// format orientation data for VRML output void S3D::FormatOrientation( std::string& result, const SGVECTOR& axis, double rotation ) { double aX; double aY; double aZ; axis.GetVector( aX, aY, aZ ); FormatFloat( result, aX ); std::string tmp; FormatFloat( tmp, aY ); result.append( " " ); result.append( tmp ); FormatFloat( tmp, aZ ); result.append( " " ); result.append( tmp ); FormatFloat( tmp, rotation ); result.append( " " ); result.append( tmp ); return; }