/usr/include/simgear/scene/util/OsgMath.hxx is in libsimgear-dev 3.0.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | // Copyright (C) 2006-2009 Mathias Froehlich - Mathias.Froehlich@web.de
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
#ifndef SIMGEAR_SCENE_UTILS_OSGMATH_HXX
#define SIMGEAR_SCENE_UTILS_OSGMATH_HXX
#include <osg/Vec2f>
#include <osg/Vec2d>
#include <osg/Vec3f>
#include <osg/Vec3d>
#include <osg/Vec4f>
#include <osg/Vec4d>
#include <osg/Quat>
#include <osg/Matrix>
#include <simgear/math/SGMath.hxx>
inline
SGVec2d
toSG(const osg::Vec2d& v)
{ return SGVec2d(v[0], v[1]); }
inline
SGVec2f
toSG(const osg::Vec2f& v)
{ return SGVec2f(v[0], v[1]); }
inline
osg::Vec2d
toOsg(const SGVec2d& v)
{ return osg::Vec2d(v[0], v[1]); }
inline
osg::Vec2f
toOsg(const SGVec2f& v)
{ return osg::Vec2f(v[0], v[1]); }
inline
SGVec3d
toSG(const osg::Vec3d& v)
{ return SGVec3d(v[0], v[1], v[2]); }
inline
SGVec3f
toSG(const osg::Vec3f& v)
{ return SGVec3f(v[0], v[1], v[2]); }
inline
osg::Vec3d
toOsg(const SGVec3d& v)
{ return osg::Vec3d(v[0], v[1], v[2]); }
inline
osg::Vec3f
toOsg(const SGVec3f& v)
{ return osg::Vec3f(v[0], v[1], v[2]); }
inline
SGVec4d
toSG(const osg::Vec4d& v)
{ return SGVec4d(v[0], v[1], v[2], v[3]); }
inline
SGVec4f
toSG(const osg::Vec4f& v)
{ return SGVec4f(v[0], v[1], v[2], v[3]); }
inline
osg::Vec4d
toOsg(const SGVec4d& v)
{ return osg::Vec4d(v[0], v[1], v[2], v[3]); }
inline
osg::Vec4f
toOsg(const SGVec4f& v)
{ return osg::Vec4f(v[0], v[1], v[2], v[3]); }
inline
SGQuatd
toSG(const osg::Quat& q)
{ return SGQuatd(q[0], q[1], q[2], q[3]); }
inline
osg::Quat
toOsg(const SGQuatd& q)
{ return osg::Quat(q[0], q[1], q[2], q[3]); }
// Create a local coordinate frame in the earth-centered frame of
// reference. X points north, Z points down.
// makeSimulationFrameRelative() only includes rotation.
inline
osg::Matrix
makeSimulationFrameRelative(const SGGeod& geod)
{ return osg::Matrix(toOsg(SGQuatd::fromLonLat(geod))); }
inline
osg::Matrix
makeSimulationFrame(const SGGeod& geod)
{
osg::Matrix result(makeSimulationFrameRelative(geod));
SGVec3d coord;
SGGeodesy::SGGeodToCart(geod, coord);
result.setTrans(toOsg(coord));
return result;
}
// Create a Z-up local coordinate frame in the earth-centered frame
// of reference. This is what scenery models, etc. expect.
// makeZUpFrameRelative() only includes rotation.
inline
osg::Matrix
makeZUpFrameRelative(const SGGeod& geod)
{
osg::Matrix result(makeSimulationFrameRelative(geod));
// 180 degree rotation around Y axis
result.preMultRotate(osg::Quat(0.0, 1.0, 0.0, 0.0));
return result;
}
inline
osg::Matrix
makeZUpFrame(const SGGeod& geod)
{
osg::Matrix result(makeZUpFrameRelative(geod));
SGVec3d coord;
SGGeodesy::SGGeodToCart(geod, coord);
result.setTrans(toOsg(coord));
return result;
}
#endif
|