Angle.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------------------+
2 |
3 | Supplied under applicable software license agreement.
4 |
5 | Copyright (c) 2018 Bentley Systems, Incorporated. All rights reserved.
6 |
7 +---------------------------------------------------------------------------------------*/
8 #pragma once
11 
14 struct GEOMDLLIMPEXP Angle
15 {
16 friend struct YawPitchRollAngles;
17 friend GEOMDLLIMPEXP Angle operator *(Angle const &, double);
18 friend GEOMDLLIMPEXP Angle operator *(double, Angle const &);
19 friend GEOMDLLIMPEXP Angle operator -(Angle const &);
20 friend GEOMDLLIMPEXP Angle operator +(Angle const &, Angle const &);
21 friend GEOMDLLIMPEXP Angle operator -(Angle const &, Angle const &);
22 
23 private: double m_radians;
24 // the constructor is PRIVATE so that callers MUST say FromDegrees or FromRadians and cannot accidentally get degrees/radians mixed up.
25 private: Angle (double radians);
27 public: Angle (AngleCR source);
28 public:
30 static Angle FromDegrees (double degrees);
31 public:
33 static Angle FromRadians (double radians);
34 public:
36 static Angle FromAtan2 (double sine, double cosine);
37 
38 public:
40 double Sin () const;
41 
42 public:
44 double Cos () const;
45 
46 public:
48  double Tan () const;
49 
50 
51 public:
53 Angle ();
54 
55 
56 public:
58 double Radians () const;
59 public:
61 double Degrees () const;
62 
64 static bool IsFullCircle (double radians);
65 
67 static bool IsNearZero (double radians);
69 static bool IsNearZeroAllowPeriodShift (double radians);
70 
72 static bool NearlyEqual (double radiansA, double radiansB);
74 static bool NearlyEqualAllowPeriodShift (double radiansA, double radiansB);
75 
77 static double SmallAngle ();
78 
80 static double TinyAngle ();
81 
82 
84 static double MediumAngle ();
85 
87 static double Pi ();
89 static double TwoPi ();
91 static double PiOver2 ();
92 
94 static double DegreesToRadians (double degrees);
96 static double RadiansToDegrees (double radians);
97 
99 static double CircleFractionToRadians (double fraction);
100 
101 
103 static double AdjustToSweep (double theta, double thetaStart, double sweep);
104 
106 static double NormalizeToSweep (double theta, double thetaStart, double sweep);
107 
122 static double NormalizeToSweep (double theta, double thetaStart, double sweep, bool extend0, bool extend1);
123 
125 static bool InExactSweep (double theta, double thetaStart, double sweep);
126 
128 static bool InSweepAllowPeriodShift (double theta, double thetaStart, double sweep);
129 
131 static double PeriodShift (double theta, double periods);
132 
134 static double ReverseComplement (double radians);
135 
141 static double ForwardComplement (double radians);
142 
144 static void HalfAngleFuctions (double &cosA, double &sinA, double rCos2A, double rSin2A);
145 
148 static void Rotate90UntilSmallAngle (double &x1, double &y1, double x0, double y0);
149 
160 static void TrigCombinationRangeInSweep
161  (
162  double constCoff, double cosCoff, double sinCoff,
163  double thetaA, double sweep,
164  double &thetaMin, double &fMin,
165  double &thetaMax, double &fMax
166  );
167 
176 static void TrigCombinationRange
177  (
178  double constCoff, double cosCoff, double sinCoff,
179  double &thetaMin, double &fMin,
180  double &thetaMax, double &fMax
181  );
182 
188 static double EvaluateTrigCombination (double constCoff, double cosCoff, double sinCoff, double theta);
190 static double Atan2 (double numerator, double denominator);
192 static double Acos (double arg);
194 static double Asin (double arg);
195 
196 
197 
199 static int Cyclic2dAxis (int i);
201 static int Cyclic3dAxis (int i);
206 static void Cyclic3dAxes (int &i0, int &i1, int &i2, int i);
207 
214 static void ApplyGivensWeights
215 (
216 double &aOut,
217 double &bOut,
218 double a,
219 double b,
220 double cos,
221 double sin
222 );
223 
230 static void ConstructGivensWeights
231 (
232 double &cosine,
233 double &sine,
234 double a,
235 double b
236 );
237 
242 static void TrigIntegrals (double theta0, double theta1, RotMatrixR integrals);
243 };
244 
245 
252  struct GEOMDLLIMPEXP AngleInDegrees
253 {
254 private:
255 double m_degrees;
256 // Private constructor with degrees as input. public users must specfiy FromDegrees or FromRadians
257 // via the static methods.
258 AngleInDegrees (double degrees);
259 
260 public:
262 AngleInDegrees ();
264 AngleInDegrees (AngleInDegrees const &other);
266 AngleInDegrees (Angle const &other);
267 
269 static AngleInDegrees SmallAngleInDegrees ();
270 
272 bool operator == (AngleInDegrees const &other) const;
274 bool operator < (AngleInDegrees const &other) const;
276 bool operator <= (AngleInDegrees const &other) const;
278 bool operator > (AngleInDegrees const &other) const;
280 bool operator >= (AngleInDegrees const &other) const;
282 bool operator != (AngleInDegrees const &other) const;
283 
285 AngleInDegrees operator+ (AngleInDegrees const &other) const {return AngleInDegrees (m_degrees + other.m_degrees);}
286 
288 bool AlmostEqual (AngleInDegrees const &other);
290 static AngleInDegrees FromRadians (double radians);
292 static AngleInDegrees FromDegrees (double degrees);
293 
295 double Degrees ()const ;
297 double Radians () const;
299 double Cos () const;
301 double Sin () const;
303 static AngleInDegrees FromAtan2 (double y, double x);
304 };
305 
316  struct GEOMDLLIMPEXP YawPitchRollAngles
317 {
318 private:
319 AngleInDegrees m_yaw, m_pitch, m_roll;
320 public:
323 
327 YawPitchRollAngles (Angle yaw, Angle pitch, Angle roll);
328 
329 AngleInDegrees GetYaw () const;
330 AngleInDegrees GetPitch () const;
331 AngleInDegrees GetRoll () const;
332 
334 static YawPitchRollAngles FromRadians (double yawRadians, double pitchRadians, double rollRadians);
335 
337 static YawPitchRollAngles FromDegrees (double yawDegrees, double pitchDegrees, double rollDegrees);
338 
340 static bool TryFromRotMatrix (YawPitchRollAnglesR angles, RotMatrixCR matrix);
342 RotMatrix ToRotMatrix () const;
344 Transform ToTransform (DPoint3dCR origin) const;
345 
347 bool IsIdentity () const;
349 double MaxAbsRadians () const;
350 
352 double MaxDiffRadians (YawPitchRollAngles const &other) const;
353 
355 double MaxAbsDegrees () const;
356 
358 double MaxDiffDegrees (YawPitchRollAngles const &other) const;
359 
360 };
struct RotMatrix & RotMatrixR
Definition: msgeomstructs_typedefs.h:135
#define END_BENTLEY_GEOMETRY_NAMESPACE
Definition: Bentley.r.h:30
bool operator<=(const basic_string< _CharT, _Traits, _Allocator > &__lhs, const basic_string< _CharT, _Traits, _Allocator > &__rhs)
Definition: basic_string.h:1376
struct YawPitchRollAngles & YawPitchRollAnglesR
Definition: msgeomstructs_typedefs.h:149
struct RotMatrix const & RotMatrixCR
Definition: msgeomstructs_typedefs.h:135
Compact (3 angles in degreses) description of rigid body rotation.
Definition: Angle.h:316
Angle object.
Definition: Angle.h:252
struct Angle const & AngleCR
Definition: msgeomstructs_typedefs.h:148
bool operator<(const basic_string< _CharT, _Traits, _Allocator > &__lhs, const basic_string< _CharT, _Traits, _Allocator > &__rhs)
Definition: basic_string.h:1326
DPoint3d operator-(DPoint3d const &point, DVec3d const &vector)
operator overload for sum of a point minus a vector
bool operator>(const basic_string< _CharT, _Traits, _Allocator > &__lhs, const basic_string< _CharT, _Traits, _Allocator > &__rhs)
Definition: basic_string.h:1366
basic_string< _CharT, _Traits, _Allocator > operator+(const basic_string< _CharT, _Traits, _Allocator > &__lhs, const basic_string< _CharT, _Traits, _Allocator > &__rhs)
Definition: basic_string.h:1230
Angle dimensional constraint which allows it to have any value between 0 and 2pi radians.
DVec3d operator*(Transform const &transform, DVec3d const &vector)
operator overload for multiplication of a transform and a vector li>The vector appears on the left as...
bool operator!=(const BentleyAllocator< _Ty > &, const BentleyAllocator< _Other > &)
Definition: BentleyAllocator.h:152
static YawPitchRollAngles FromDegrees(double yawDegrees, double pitchDegrees, double rollDegrees)
constructor from all angles in degrees
bool operator>=(const basic_string< _CharT, _Traits, _Allocator > &__lhs, const basic_string< _CharT, _Traits, _Allocator > &__rhs)
Definition: basic_string.h:1386
The Angle class has static methods for typical angle computations.
Definition: Angle.h:14
#define BEGIN_BENTLEY_GEOMETRY_NAMESPACE
Definition: Bentley.r.h:29
struct DPoint3d const & DPoint3dCR
Definition: msgeomstructs_typedefs.h:79
static YawPitchRollAngles FromRadians(double yawRadians, double pitchRadians, double rollRadians)
constructor from all angles in radians
bool operator==(const BentleyAllocator< _Ty > &, const BentleyAllocator< _Other > &)
Definition: BentleyAllocator.h:146

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.