gwnavgeneration/raster/rastertriangle.h Source File

rastertriangle.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 
8 // primary contact: GUAL - secondary contact: NOBODY
9 #ifndef GwNavGen_RasterTriangle_H
10 #define GwNavGen_RasterTriangle_H
11 
17 
18 
19 namespace Kaim
20 {
21 
22 class Triangle3i;
23 
24 
25 class RasterTriangle
26 {
27 public:
28  RasterTriangle();
29 
30  bool Setup(const Triangle3i& triangle, KyFloat32 rasterPrecisionInMeter);
31 
32  bool Setup(const RasterPoint& rpA, const RasterPoint& rpB, const RasterPoint& rpC, KyFloat32 rasterPrecisionInMeter);
33 
34  KY_INLINE KyFloat32 meterZ(Coord x, Coord y)
35  {
36  KyFloat32 meter_AMx = IntCoordSystem::IntToNavigation_Dist(x - iA.x, m_rasterPrecisionInMeter);
37  KyFloat32 meter_AMy = IntCoordSystem::IntToNavigation_Dist(y - iA.y, m_rasterPrecisionInMeter);
38  return A.z - (meter_AMx * N.x + meter_AMy * N.y) * inv_Nz;
39  }
40 
41  KyFloat32 meterStepZ_AlongX(Coord dx) { return dz_on_dx * IntCoordSystem::IntToNavigation_Dist(dx, m_rasterPrecisionInMeter); }
42 
43  /* Returns true if M is inside triangle or exactly on one edge. */
44  bool IsInside2d(const Vec2i& M) const { return M.IsInsideTriangle(iA, iB, iC); }
45 
46  /* Returns true if M is inside triangle or exactly on one edge. We assume the triangle is not colinear in this test. */
47  bool IsInside2d_NoColinear(const Vec2i& M) const { return M.IsInsideNotColinearTriangle(iA, iB, iC); }
48 
49  /* Returns true if M is strictly inside triangle. */
50  bool IsStrictlyInside2d(const Vec2i& M) const { return M.IsStrictlyInsideTriangle(iA, iB, iC); }
51 
52 public:
53  Vec2i iA, iB, iC;
54 
55  Vec3f A;
56  Vec3f AB;
57  Vec3f AC;
58  Vec3f N;
59  KyFloat32 inv_Nz;
60  KyFloat32 dz_on_dx;
61  KyFloat32 m_rasterPrecisionInMeter;
62 };
63 
64 
65 }
66 
67 
68 #endif
Definition: gamekitcrowddispersion.h:20
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43