OpenFrames
DoubleSingleUtils.hpp
Go to the documentation of this file.
1 /***********************************
2  Copyright 2018 Ravishankar Mathur
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 ***********************************/
16 
21 #ifndef _OF_DOUBLESINGLEUTILS_
22 #define _OF_DOUBLESINGLEUTILS_
23 
24 #include <OpenFrames/Export.h>
25 #include <osg/Vec3d>
26 #include <osg/Vec3f>
27 
28 /***********************************************************
29  * Ravi Mathur
30  * OpenFrames API, Double-Single Utilities
31  * Provides utility functions to represent osg::Vec3d as
32  * a pair of osg::Vec3f.
33 ***********************************************************/
34 namespace OpenFrames
35 {
36 
37  // Split Vec3d into two Vec3f
38  static inline void DS_Split(const osg::Vec3d &point, osg::Vec3f &high, osg::Vec3f &low)
39  {
40  high = point;
41  low = point - high;
42  }
43 
44  // Perform a - b, where a and b are pairs of Vec3f
45  static inline void DS_Subtract(const osg::Vec3f &a_high,
46  const osg::Vec3f &a_low,
47  const osg::Vec3f &b_high,
48  const osg::Vec3f &b_low,
49  osg::Vec3f &result)
50  {
51  osg::Vec3f t1, t2, e, c_high, c_low;
52  t1 = a_low - b_low;
53  e = t1 - a_low;
54  t2 = ((-b_low - e) + (a_low - (t1 - e))) + a_high - b_high;
55 
56  c_high = t1 + t2;
57  c_low = t2 - (c_high - t1);
58  result = c_high + c_low;
59  }
60 
61 }
62 #endif
Definition: CoordinateAxes.hpp:29