3 // Copyright (C) 2011 Curtis L Olson <curt@flightgear.org>
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Library General Public
7 // License as published by the Free Software Foundation; either
8 // version 2 of the License, or (at your option) any later version.
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Library General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 # include <simgear_config.h>
24 #include <simgear/math/SGMath.hxx>
27 #include <osg/Matrixd>
29 osg::Matrix SGGeod::makeSimulationFrameRelative() const
31 SGQuatd hlOr = SGQuatd::fromLonLat(*this);
32 return osg::Matrix(toOsg(hlOr));
35 osg::Matrix SGGeod::makeSimulationFrame() const
37 osg::Matrix result(makeSimulationFrameRelative());
39 SGGeodesy::SGGeodToCart(*this, coord);
40 result.setTrans(toOsg(coord));
44 osg::Matrix SGGeod::makeZUpFrameRelative() const
46 osg::Matrix result(makeSimulationFrameRelative());
47 // 180 degree rotation around Y axis
48 osg::Quat flip(0.0, 1.0, 0.0, 0.0);
49 result.preMult(osg::Matrix(flip));
53 osg::Matrix SGGeod::makeZUpFrame() const
55 osg::Matrix result(makeZUpFrameRelative());
57 SGGeodesy::SGGeodToCart(*this, coord);
58 result.setTrans(toOsg(coord));