gwnavruntime/math/minmaxonaxis.h Source File

minmaxonaxis.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 #pragma once
8 
12 
13 namespace Kaim
14 {
15 
16 class MinMaxOnAxis // class with static functions only
17 {
18 public:
19  KY_INLINE static void GetSegment2(const Vec2f& OA, const Vec2f& OB, const Vec2f& axis, KyFloat32& xmin, KyFloat32& xmax)
20  {
21  const KyFloat32 a = DotProduct(OA, axis);
22  const KyFloat32 b = DotProduct(OB, axis);
23  xmin = Kaim::Min(a, b);
24  xmax = Kaim::Max(a, b);
25  }
26 
27  KY_INLINE static void GetSegment2(const Vec2LL& OA, const Vec2LL& OB, const Vec2LL& axis, KyInt64& xmin, KyInt64& xmax)
28  {
29  const KyInt64 a = DotProduct(OA, axis);
30  const KyInt64 b = DotProduct(OB, axis);
31  xmin = Kaim::FastMin(a, b);
32  xmax = Kaim::FastMax(a, b);
33  }
34 
35  KY_INLINE static void Get2(const Vec2f& A, const Vec2f& B, const Vec2f& O, const Vec2f& axis, KyFloat32& xmin, KyFloat32& xmax) { GetSegment2(A - O, B - O, axis, xmin, xmax); }
36  KY_INLINE static void Get2(const Vec2LL& A, const Vec2LL& B, const Vec2LL& O, const Vec2LL& axis, KyInt64& xmin, KyInt64& xmax) { GetSegment2(A - O, B - O, axis, xmin, xmax); }
37 
38  KY_INLINE static void Get3(const Vec2f& A, const Vec2f& B, const Vec2f& C, const Vec2f& O, const Vec2f& axis, KyFloat32& xmin, KyFloat32& xmax)
39  {
40  const KyFloat32 a = DotProduct(A - O, axis);
41  const KyFloat32 b = DotProduct(B - O, axis);
42  const KyFloat32 c = DotProduct(C - O, axis);
43  xmin = Kaim::Min(a, b, c);
44  xmax = Kaim::Max(a, b, c);
45  }
46 
47  KY_INLINE static void Get3(const Vec2LL& A, const Vec2LL& B, const Vec2LL& C, const Vec2LL& O, const Vec2LL& axis, KyInt64& xmin, KyInt64& xmax)
48  {
49  const KyInt64 a = DotProduct(A - O, axis);
50  const KyInt64 b = DotProduct(B - O, axis);
51  const KyInt64 c = DotProduct(C - O, axis);
52  xmin = Kaim::FastMin(a, b, c);
53  xmax = Kaim::FastMax(a, b, c);
54  }
55 
56  KY_INLINE static void Get4(const Vec2f& A, const Vec2f& B, const Vec2f& C, const Vec2f& D, const Vec2f& O, const Vec2f& axis, KyFloat32& xmin, KyFloat32& xmax)
57  {
58  const KyFloat32 a = DotProduct(A - O, axis);
59  const KyFloat32 b = DotProduct(B - O, axis);
60  const KyFloat32 c = DotProduct(C - O, axis);
61  const KyFloat32 d = DotProduct(D - O, axis);
62  xmin = Kaim::Min(a, b, c, d);
63  xmax = Kaim::Max(a, b, c, d);
64  }
65 
66  KY_INLINE static void Get4(const Vec2LL& A, const Vec2LL& B, const Vec2LL& C, const Vec2LL& D, const Vec2LL& O, const Vec2LL& axis, KyInt64& xmin, KyInt64& xmax)
67  {
68  const KyInt64 a = DotProduct(A - O, axis);
69  const KyInt64 b = DotProduct(B - O, axis);
70  const KyInt64 c = DotProduct(C - O, axis);
71  const KyInt64 d = DotProduct(D - O, axis);
72  xmin = Kaim::FastMin(a, b, c, d);
73  xmax = Kaim::FastMax(a, b, c, d);
74  }
75 
76  KY_INLINE static void Get4(const Vec2i& A, const Vec2i& B, const Vec2i& C, const Vec2i& D, const Vec2i& O, const Vec2i& axis, KyInt32& xmin, KyInt32& xmax)
77  {
78  const KyInt32 a = DotProduct(A - O, axis);
79  const KyInt32 b = DotProduct(B - O, axis);
80  const KyInt32 c = DotProduct(C - O, axis);
81  const KyInt32 d = DotProduct(D - O, axis);
82  xmin = Kaim::FastMin(a, b, c, d);
83  xmax = Kaim::FastMax(a, b, c, d);
84  }
85 
86  KY_INLINE static void Get1AndOrig(const Vec2f& A, const Vec2f& O, const Vec2f& axis, KyFloat32& xmin, KyFloat32& xmax)
87  {
88  const KyFloat32 a = DotProduct(A - O, axis);
89  xmin = Kaim::Min(a, 0.0f);
90  xmax = Kaim::Max(a, 0.0f);
91  }
92 
93  KY_INLINE static void Get1AndOrig(const Vec2LL& A, const Vec2LL& O, const Vec2LL& axis, KyInt64& xmin, KyInt64& xmax)
94  {
95  const KyInt64 a = DotProduct(A - O, axis);
96  xmin = Kaim::FastMin(a, 0LL);
97  xmax = Kaim::FastMax(a, 0LL);
98  }
99 
100  KY_INLINE static void Get2AndOrig(const Vec2f& A, const Vec2f& B, const Vec2f& O, const Vec2f& axis, KyFloat32& xmin, KyFloat32& xmax)
101  {
102  const KyFloat32 a = DotProduct(A - O, axis);
103  const KyFloat32 b = DotProduct(B - O, axis);
104  xmin = Kaim::Min(a, b, 0.0f);
105  xmax = Kaim::Max(a, b, 0.0f);
106  }
107 
108 };
109 
110 }
111 
std::int64_t KyInt64
int64_t
Definition: types.h:25
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
std::int32_t KyInt32
int32_t
Definition: types.h:24
float KyFloat32
float
Definition: types.h:32