1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #pragma once19 20 #include "../MathGeoLibFwd.h"21 #include "[LineSegment.h]"22 23 [MATH_BEGIN_NAMESPACE]24 25 26 class [Capsule]27 {28 public:29 30 [LineSegment] [l];31 32 33 float [r];34 35 36 37 38 39 [Capsule]() {}40 41 42 43 44 45 [Capsule](const [LineSegment] &endPoints, float radius);46 47 48 49 50 51 [Capsule](const vec &bottomPoint, const vec &topPoint, float radius);52 53 54 55 56 void [SetFrom](const [Sphere] &s);57 58 59 void [SetDegenerate]();60 61 62 63 bool [IsDegenerate]() const;64 65 66 67 68 float [LineLength]() const;69 70 71 72 73 float [Height]() const;74 75 76 77 78 79 float [Diameter]() const;80 81 82 83 84 85 86 87 88 vec [Bottom]() const;89 90 91 92 93 94 vec [Center]() const;95 vec [Centroid]() const { return [l].[CenterPoint](); } 96 97 98 inline vec [AnyPointFast]() const { return [l].[a]; }99 100 101 102 103 104 105 106 vec [ExtremePoint](const vec &direction) const;107 vec [ExtremePoint](const vec &direction, float &projectionDistance) const;108 109 110 111 112 113 114 115 116 void [ProjectToAxis](const vec &direction, float &outMin, float &outMax) const;117 118 119 120 121 122 123 124 125 vec [Top]() const;126 127 128 129 130 131 vec [UpDirection]() const;132 133 134 135 136 float [Volume]() const;137 138 139 140 141 float [SurfaceArea]() const;142 143 144 145 146 147 [Circle] [CrossSection](float [l]) const;148 149 150 151 152 [LineSegment] [HeightLineSegment]() const;153 154 155 156 157 158 159 160 bool [IsFinite]() const;161 162 163 164 165 166 167 168 vec [PointInside](float [l], float a, float [d]) const;169 170 171 172 173 174 175 176 vec [UniformPointPerhapsInside](float [l], float x, float y) const;177 178 179 [Sphere] [SphereA]() const;180 181 182 [Sphere] [SphereB]() const;183 184 185 186 [AABB] [MinimalEnclosingAABB]() const;187 188 189 190 [OBB] [MinimalEnclosingOBB]() const;191 192 193 194 195 vec [RandomPointInside]([LCG] &rng) const;196 197 198 199 200 201 vec [RandomPointOnSurface]([LCG] &rng) const;202 203 204 205 206 207 void [Translate](const vec &offset);208 209 210 211 212 213 214 215 void [Scale](const vec ¢erPoint, float scaleFactor);216 217 218 219 220 221 222 void [Transform](const [float3x3] &transform);223 void [Transform](const [float3x4] &transform);224 void [Transform](const [float4x4] &transform);225 void [Transform](const [Quat] &transform);226 227 228 229 230 231 vec [ClosestPoint](const vec &targetPoint) const;232 233 234 235 236 237 238 float [Distance](const vec &point) const;239 float [Distance](const [Plane] &plane) const;240 float [Distance](const [Sphere] &sphere) const;241 float [Distance](const [Ray] &ray) const;242 float [Distance](const [Line] &line) const;243 float [Distance](const [LineSegment] &lineSegment) const;244 float [Distance](const [Capsule] &capsule) const;245 246 247 248 249 250 251 252 bool [Contains](const vec &point) const;253 bool [Contains](const [LineSegment] &lineSegment) const;254 bool [Contains](const [Triangle] &triangle) const;255 bool [Contains](const [Polygon] &polygon) const;256 bool [Contains](const [AABB] &aabb) const;257 bool [Contains](const [OBB] &obb) const;258 bool [Contains](const [Frustum] &frustum) const;259 bool [Contains](const [Polyhedron] &polyhedron) const;260 261 262 263 264 265 266 267 268 bool [Intersects](const [Ray] &ray) const;269 bool [Intersects](const [Line] &line) const;270 bool [Intersects](const [LineSegment] &lineSegment) const;271 bool [Intersects](const [Plane] &plane) const;272 bool [Intersects](const [Sphere] &sphere) const;273 bool [Intersects](const [Capsule] &capsule) const;274 bool [Intersects](const [AABB] &aabb) const;275 bool [Intersects](const [OBB] &obb) const;276 bool [Intersects](const [Triangle] &triangle) const;277 bool [Intersects](const [Polygon] &polygon) const;278 bool [Intersects](const [Frustum] &frustum) const;279 bool [Intersects](const [Polyhedron] &polyhedron) const;280 281 #ifdef MATH_ENABLE_STL_SUPPORT282 283 284 std::string [ToString]() const;285 std::string [SerializeToString]() const;286 287 288 std::string [SerializeToCodeString]() const;289 #endif290 291 static [Capsule] [FromString](const char *str, const char **outEndStr = 0);292 #ifdef MATH_ENABLE_STL_SUPPORT293 static [Capsule] [FromString](const std::string &str) { return [FromString](str.c_str()); }294 #endif295 296 #ifdef MATH_QT_INTEROP297 operator QString() const { return toString(); }298 QString toString() const { return QString::fromStdString([ToString]()); }299 #endif300 301 bool [Equals](const [Capsule] &rhs, float [epsilon] = 1[e]-3f) const { return [l].[Equals](rhs.[l], [epsilon]) && [EqualAbs]([r], rhs.[r], [epsilon]); }302 303 304 305 bool [BitEquals](const [Capsule] &other) const;306 };307 308 [Capsule] [operator *](const [float3x3] &transform, const [Capsule] &capsule);309 [Capsule] [operator *](const [float3x4] &transform, const [Capsule] &capsule);310 [Capsule] [operator *](const [float4x4] &transform, const [Capsule] &capsule);311 [Capsule] [operator *](const [Quat] &transform, const [Capsule] &capsule);312 313 #ifdef MATH_QT_INTEROP314 Q_DECLARE_METATYPE([Capsule])315 Q_DECLARE_METATYPE([Capsule]*)316 #endif317 318 #ifdef MATH_ENABLE_STL_SUPPORT319 std::ostream &[operator <<](std::ostream &o, const [Capsule] &capsule);320 #endif321 322 [MATH_END_NAMESPACE] Go back to previous page