SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLAlgo Namespace Reference

Collection of algorithms that may should be integrated into other namespaces. More...

Functions

bool estimateHorizon (const SLMat3f &enuRs, const SLMat3f &sRc, SLVec3f &horizon)
 
template<typename T >
geoDegMinSec2Decimal (int degrees, int minutes, T seconds)
 convert geodetic datum defined in degrees, minutes and seconds to decimal More...
 
template float geoDegMinSec2Decimal (int degrees, int minutes, float seconds)
 
template double geoDegMinSec2Decimal (int degrees, int minutes, double seconds)
 
template<typename T >
SLVec3< T > geoDegMinSec2Decimal (int degreesLat, int minutesLat, T secondsLat, int degreesLon, int minutesLon, T secondsLon, T alt)
 Latitude Longitude Altitude (LatLonAlt), defined in Degrees, Minutes, Secondes format to decimal. More...
 
template SLVec3f geoDegMinSec2Decimal (int degreesLat, int minutesLat, float secondsLat, int degreesLon, int minutesLon, float secondsLon, float altM)
 
template SLVec3d geoDegMinSec2Decimal (int degreesLat, int minutesLat, double secondsLat, int degreesLon, int minutesLon, double secondsLon, double altM)
 

Detailed Description

Collection of algorithms that may should be integrated into other namespaces.

Function Documentation

◆ estimateHorizon()

bool SLAlgo::estimateHorizon ( const SLMat3f enuRs,
const SLMat3f sRc,
SLVec3f horizon 
)

Definition at line 17 of file SLAlgo.cpp.

18 {
19  SLMat3f cRenu = (enuRs * sRc).transposed();
20  //estimate horizon in camera frame:
21  //-normal vector of camera x-y-plane in enu frame definition: this is the camera z-axis epressed in enu frame
22  SLVec3f normalCamXYPlane = SLVec3f(0, 0, 1);
23  //-normal vector of enu x-y-plane in camera frame: this is the enu z-axis rotated into camera coord. frame
24  SLVec3f normalEnuXYPlane = cRenu * SLVec3f(0, 0, 1);
25  //-Estimation of intersetion line (horizon):
26  //Then the crossproduct of both vectors defines the direction of the intersection line. In our special case we know that the origin is a point that lies on both planes.
27  //Then origin together with the direction vector define the horizon.
28  horizon.cross(normalEnuXYPlane, normalCamXYPlane);
29 
30  //check that vectors are not parallel
31  float l = horizon.length();
32  if (l < 0.01f)
33  {
34  horizon = {1.f, 0.f, 0.f};
35  return false;
36  }
37  else
38  {
39  horizon /= l;
40  return true;
41  }
42 }
SLVec3< SLfloat > SLVec3f
Definition: SLVec3.h:318
void cross(const SLVec3 &a, const SLVec3 &b)
Definition: SLVec3.h:118
T length() const
Definition: SLVec3.h:122

◆ geoDegMinSec2Decimal() [1/6]

template double SLAlgo::geoDegMinSec2Decimal ( int  degrees,
int  minutes,
double  seconds 
)

◆ geoDegMinSec2Decimal() [2/6]

template float SLAlgo::geoDegMinSec2Decimal ( int  degrees,
int  minutes,
float  seconds 
)

◆ geoDegMinSec2Decimal() [3/6]

template<typename T >
T SLAlgo::geoDegMinSec2Decimal ( int  degrees,
int  minutes,
seconds 
)

convert geodetic datum defined in degrees, minutes and seconds to decimal

Definition at line 45 of file SLAlgo.cpp.

46 {
47  return (T)degrees + ((T)(minutes * 60) + seconds) / ((T)3600);
48 }

◆ geoDegMinSec2Decimal() [4/6]

template SLVec3d SLAlgo::geoDegMinSec2Decimal ( int  degreesLat,
int  minutesLat,
double  secondsLat,
int  degreesLon,
int  minutesLon,
double  secondsLon,
double  altM 
)

◆ geoDegMinSec2Decimal() [5/6]

template SLVec3f SLAlgo::geoDegMinSec2Decimal ( int  degreesLat,
int  minutesLat,
float  secondsLat,
int  degreesLon,
int  minutesLon,
float  secondsLon,
float  altM 
)

◆ geoDegMinSec2Decimal() [6/6]

template<typename T >
SLVec3< T > SLAlgo::geoDegMinSec2Decimal ( int  degreesLat,
int  minutesLat,
secondsLat,
int  degreesLon,
int  minutesLon,
secondsLon,
altM 
)

Latitude Longitude Altitude (LatLonAlt), defined in Degrees, Minutes, Secondes format to decimal.

Definition at line 55 of file SLAlgo.cpp.

58 {
59  //https://www.koordinaten-umrechner.de/
60  assert(degreesLat > -90 && degreesLat < 90);
61  assert(degreesLon > -180 && degreesLon < 180);
62  assert(minutesLat > 0 && minutesLat < 60);
63  assert(minutesLon > 0 && minutesLon < 60);
64  assert(secondsLat >= (T)0 && secondsLat < (T)60);
65  assert(secondsLon >= (T)0 && secondsLon < (T)60);
66 
67  SLVec3<T> vec;
68  vec.x = geoDegMinSec2Decimal<T>(degreesLat, minutesLat, secondsLat);
69  vec.y = geoDegMinSec2Decimal<T>(degreesLon, minutesLon, secondsLon);
70  vec.z = altM;
71 
72  return vec;
73 }
T y
Definition: SLVec3.h:43
T x
Definition: SLVec3.h:43
T z
Definition: SLVec3.h:43