vsg: include/vsg/app/EllipsoidModel.h Source File

vsg 1.1.9 VulkanSceneGraph library |

Loading...
Searching...
No Matches
EllipsoidModel.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2018 Robert Osfield
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
9The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
11THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
13</editor-fold> */
14
15#include <vsg/core/Inherit.h>
16#include <vsg/maths/mat4.h>
17#include <vsg/maths/vec3.h>
18
19namespace vsg
20{
21
22 const double WGS_84_RADIUS_EQUATOR = 6378137.0;
23 const double WGS_84_RADIUS_POLAR = 6356752.3142;
24
27 class VSG_DECLSPEC EllipsoidModel : public Inherit<Object, EllipsoidModel>
28 {
29 public:
30 explicit EllipsoidModel(double rEquator = WGS_84_RADIUS_EQUATOR, double rPolar = WGS_84_RADIUS_POLAR);
31
32 bool operator==(const EllipsoidModel& rhs) const
33 {
34 return _radiusEquator == rhs._radiusEquator && _radiusPolar == rhs._radiusPolar;
35 }
36
37 bool operator!=(const EllipsoidModel& rhs) const
38 {
39 return _radiusEquator != rhs._radiusEquator || _radiusPolar != rhs._radiusPolar;
40 }
41
42 double radiusEquator() const { return _radiusEquator; }
43 double radiusPolar() const { return _radiusPolar; }
44
45 void read(Input& input) override;
46 void write(Output& output) const override;
47
49 dvec3 convertLatLongAltitudeToECEF(const dvec3& lla) const;
50
52 dvec3 convertECEFToLatLongAltitude(const dvec3& ecef) const;
53
55 dmat4 computeLocalToWorldTransform(const dvec3& lla) const;
56
58 dmat4 computeWorldToLocalTransform(const dvec3& lla) const;
59
60 protected:
61 void _computeEccentricitySquared();
62
63 double _radiusEquator;
64 double _radiusPolar;
65 double _eccentricitySquared;
66 };
67 VSG_type_name(vsg::EllipsoidModel);
68
69} // namespace vsg
vsg::EllipsoidModel
Definition EllipsoidModel.h:28
vsg::EllipsoidModel::convertECEFToLatLongAltitude
dvec3 convertECEFToLatLongAltitude(const dvec3 &ecef) const
latitude and longitude in degrees, altitude in metres, ECEF coords in metres.
vsg::EllipsoidModel::computeWorldToLocalTransform
dmat4 computeWorldToLocalTransform(const dvec3 &lla) const
latitude and longitude in degrees, altitude in metres
vsg::EllipsoidModel::computeLocalToWorldTransform
dmat4 computeLocalToWorldTransform(const dvec3 &lla) const
latitude and longitude in degrees, altitude in metres
vsg::EllipsoidModel::convertLatLongAltitudeToECEF
dvec3 convertLatLongAltitudeToECEF(const dvec3 &lla) const
latitude and longitude in degrees, altitude in metres, ECEF coords in metres.
vsg::Input
Definition Input.h:44
vsg::Output
Definition Output.h:41