gwnavruntime/math/triangle3i.h Source File

triangle3i.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 Navigation_Triangle3i_H
10 #define Navigation_Triangle3i_H
11 
13 
14 
15 namespace Kaim
16 {
17 
18 
22 class Triangle3i
23 {
24  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
25 
26 public:
27  // ---------------------------------- Public Member Functions ----------------------------------
28 
33  void Set(const Vec3i& _a, const Vec3i& _b, const Vec3i& _c) { A = _a; B = _b; C = _c; }
34 
36  Vec3i& operator[](KyInt32 i) { return (&A)[i]; }
37 
39  const Vec3i& operator[](KyInt32 i) const { return (&A)[i]; }
40 
43  KyUInt32 IsInside2d(const Vec2i& M) const { return M.IsInsideTriangle(Vec2i(A.x, A.y), Vec2i(B.x, B.y), Vec2i(C.x, C.y)); }
44 
47  bool IsInside2d_NoFlat(const Vec2i& M) const { return M.IsInsideNotColinearTriangle(Vec2i(A.x, A.y), Vec2i(B.x, B.y), Vec2i(C.x, C.y)); }
48 
50  bool IsStrictlyInside2d(const Vec2i& M) const { return M.IsStrictlyInsideTriangle(Vec2i(A.x, A.y), Vec2i(B.x, B.y), Vec2i(C.x, C.y)); }
51 
52 
53  // ---------------------------------- Public Data Members ----------------------------------
54 
55  Vec3i A;
56  Vec3i B;
57  Vec3i C;
58 };
59 
62 inline void SwapEndianness(Endianness::Target e, Triangle3i& self)
63 {
64  SwapEndianness(e, self.A);
65  SwapEndianness(e, self.B);
66  SwapEndianness(e, self.C);
67 }
68 
69 
70 }
71 
72 
73 #endif
74 
This class defines a three-dimensional vector whose coordinates are stored using 32-bit integers...
Definition: vec3i.h:21
Vec3i A
The position of the first corner of the triangle.
Definition: triangle3i.h:65
void Set(const Vec3i &_a, const Vec3i &_b, const Vec3i &_c)
Sets the coordinates of the three points that make up the triangle.
Definition: triangle3i.h:39
Vec3i & operator[](KyInt32 i)
Retrieves the coordinates of the specified corner of the triangle. Use only [0], [1], or [2].
Definition: triangle3i.h:42
int KyInt32
Type used internally to represent a 32-bit integer.
Definition: types.h:35
KyInt32 x
The size of the vector along the X axis.
Definition: vec3i.h:180
bool IsInside2d_NoFlat(const Vec2i &M) const
Returns true if the (X,Y) coordinates of the specified point lie inside the (X,Y) extents of the tria...
Definition: triangle3i.h:53
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:35
bool IsInsideTriangle(const Vec2i &A, const Vec2i &B, const Vec2i &C) const
Returns true if this vector is inside the clockwise triangle formed by theA,B and C parameters...
Definition: vec2i.h:304
KyInt32 y
The size of the vector along the Y axis.
Definition: vec3i.h:181
KyUInt32 IsInside2d(const Vec2i &M) const
Returns true if the (X,Y) coordinates of the specified point lie inside the (X,Y) extents of the tria...
Definition: triangle3i.h:49
This class defines a two-dimensional vector whose coordinates are stored using 32-bit integers...
Definition: vec2i.h:26
Definition: gamekitcrowddispersion.h:20
Vec3i B
The position of the second corner of the triangle.
Definition: triangle3i.h:66
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
This class represents a triangle in three-dimensional space, whose dimensions are stored using intege...
Definition: triangle3i.h:23
bool IsStrictlyInside2d(const Vec2i &M) const
Returns true if the (X,Y) coordinates of the specified point lie strictly inside the (X...
Definition: triangle3i.h:56
Vec3i C
The position of the third corner of the triangle.
Definition: triangle3i.h:67