gwnavgeneration/raster/rastertriangle.h Source File

rastertriangle.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 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 #pragma once
9 
15 
16 
17 namespace Kaim
18 {
19 
20 class Triangle3i;
21 
22 
23 class RasterTriangle
24 {
25 public:
26  RasterTriangle();
27 
28  bool Setup(const Triangle3i& triangle, KyFloat32 rasterPrecisionInMeter);
29 
30  bool Setup(const RasterPoint& rpA, const RasterPoint& rpB, const RasterPoint& rpC, KyFloat32 rasterPrecisionInMeter);
31 
32  KY_INLINE KyFloat32 meterZ(Coord x, Coord y)
33  {
34  KyFloat32 meter_AMx = IntCoordSystem::IntToNavigation_Dist(x - iA.x, m_rasterPrecisionInMeter);
35  KyFloat32 meter_AMy = IntCoordSystem::IntToNavigation_Dist(y - iA.y, m_rasterPrecisionInMeter);
36  return A.z - (meter_AMx * N.x + meter_AMy * N.y) * inv_Nz;
37  }
38 
39  KyFloat32 meterStepZ_AlongX(Coord dx) { return dz_on_dx * IntCoordSystem::IntToNavigation_Dist(dx, m_rasterPrecisionInMeter); }
40 
41  /* Returns true if M is inside triangle or exactly on one edge. */
42  bool IsInside2d(const Vec2i& M) const { return M.IsInsideTriangle(iA, iB, iC); }
43 
44  /* Returns true if M is inside triangle or exactly on one edge. We assume the triangle is not colinear in this test. */
45  bool IsInside2d_NoColinear(const Vec2i& M) const { return M.IsInsideNotColinearTriangle(iA, iB, iC); }
46 
47  /* Returns true if M is strictly inside triangle. */
48  bool IsStrictlyInside2d(const Vec2i& M) const { return M.IsStrictlyInsideTriangle(iA, iB, iC); }
49 
50 public:
51  Vec2i iA, iB, iC;
52 
53  Vec3f A;
54  Vec3f AB;
55  Vec3f AC;
56  Vec3f N;
57  KyFloat32 inv_Nz;
58  KyFloat32 dz_on_dx;
59  KyFloat32 m_rasterPrecisionInMeter;
60 };
61 
62 
63 }
64 
65 
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
float KyFloat32
float
Definition: types.h:32