EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Trig.h
Go to the documentation of this file.
1 
10 #include "math/gpoint.h"
11 
12 // EvE uses the 3d left hand cartesian coordinate system, centered on star.
13 // +x is left, +y is up elevation, +z is "into", or up in 2d
14 
15 namespace EvE {
16 
17  namespace Trig {
18 
19  const double E = 2.71828182845904523536028747135;
20  const double Pi = 3.1415926535897932384626433832795;
21  const double Pi2 = 6.28318530717958647692528676656;
22  const double RadiansInDegrees = 0.0174532925199432957692369076849; // pi/180
23  const double DegreesInRadians = 57.2957795130823208767981548141; // 180/pi
24 
25  inline double Deg2Rad(double deg) { return (deg * RadiansInDegrees); }
26  inline double Rad2Deg(double rad) { return (rad * DegreesInRadians); }
27 
28 
29 
30 /*
31  * azimuth is the counterclockwise angle in the x-y plane measured in radians from the positive x-axis.
32  * elevation is the elevation angle in radians from the x-y plane.
33  */
34 
35 /*
36 The mapping from spherical coordinates to three-dimensional Cartesian coordinates is
37 
38 x = r .* cos(elevation) .* cos(azimuth)
39 y = r .* cos(elevation) .* sin(azimuth)
40 z = r .* sin(elevation)
41 */
42  //GPoint Sph2Cart(float az, float ele, float radius) { }
43 
44 /*The mapping from three-dimensional Cartesian coordinates to spherical coordinates is
45 
46 azimuth = atan2(y,x)
47 elevation = atan2(z,sqrt(x.^2 + y.^2))
48 r = sqrt(x.^2 + y.^2 + z.^2)
49 
50 The notation for spherical coordinates is not standard.
51 For the cart2sph function, elevation is measured from the x-y plane.
52 Notice that if elevation = 0, the point is in the x-y plane.
53 If elevation = pi/2, then the point is on the positive z-axis.
54 */
55 
56  //void Cart2Sph(GPoint pos, float& az, float& ele, float& radius) { }
57 
58 
59  }
60 }
61 
62 /*
63  * def RayToPlaneIntersection(P, d, Q, n):
64  * """
65  * The intersection point(S) on a plane where d shot from P would intersect
66  * the plane defined by Q and n.
67  *
68  * If the P lies on the plane defined by n and Q, there are infinite number of
69  * intersection points so the function returns P.
70  *
71  * d' = - Q.Dot(n)
72  * t = -(n.Dot(P) + d' )/n.Dot(d)
73  * S = P + t*d
74  * """
75  * denom = geo2.Vec3Dot(n, d)
76  * if abs(denom) < 1e-05:
77  * return P
78  * else:
79  * distance = -geo2.Vec3Dot(Q, n)
80  * t = -(geo2.Vec3Dot(n, P) + distance) / denom
81  * scaledRay = geo2.Scale(d, t)
82  * ret = geo2.Add(scaledRay, P)
83  * return geo2.Vector(*ret)
84  */
const double Pi
Definition: Trig.h:20
double Rad2Deg(double rad)
Definition: Trig.h:26
const double Pi2
Definition: Trig.h:21
double Deg2Rad(double deg)
Definition: Trig.h:25
Definition: Trig.h:15
const double DegreesInRadians
Definition: Trig.h:23
const double E
Definition: Trig.h:19
const double RadiansInDegrees
Definition: Trig.h:22