OGRE  1.8
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreSegment.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 OgreSegment.h - 3D Line Segment class for intersection testing in Ogre3D
28 Some algorithms based off code from the Wild Magic library by Dave Eberly
29 -----------------------------------------------------------------------------
30 begin : Mon Apr 02 2007
31 author : Eric Cha
32 email : ericc@xenopi.com
33 Code Style Update : Apr 5, 2007
34 -----------------------------------------------------------------------------
35 */
36 
37 #ifndef SEGMENT_H
38 #define SEGMENT_H
39 
40 #include "OgreVector3.h"
41 
42 namespace Ogre
43 {
44  class Capsule;
45 
46  class Segment
47  {
48  public:
49  // The segment is represented as P+t*D, where P is the segment origin,
50  // D is a unit-length direction vector and |t| <= e. The value e is
51  // referred to as the extent of the segment. The end points of the
52  // segment are P-e*D and P+e*D. The user must ensure that the direction
53  // vector is unit-length. The representation for a segment is analogous
54  // to that for an oriented bounding box. P is the center, D is the
55  // axis direction, and e is the extent.
56 
57 
58  // construction
59  Segment (); // uninitialized
60  Segment (const Vector3&, const Vector3&, Real);
61 
62  // set values
63  void set(const Vector3& newOrigin, const Vector3& newEnd);
64  void setOrigin(const Vector3& newOrigin);
65  void setEndPoint(const Vector3& newEndpoint);
66 
67  // functions to calculate distance to another segment
68  Real distance(const Segment& otherSegment) const;
69  Real squaredDistance(const Segment& otherSegment) const;
70 
71  // intersect check between segment & capsule
72  bool intersects(const Capsule&) const;
73 
74  // defining variables
78  };
79 }
80 
81 #endif //SEGMENT_H
void setOrigin(const Vector3 &newOrigin)
float Real
Software floating point type.
Real squaredDistance(const Segment &otherSegment) const
bool intersects(const Capsule &) const
void set(const Vector3 &newOrigin, const Vector3 &newEnd)
Real distance(const Segment &otherSegment) const
Vector3 mDirection
Definition: OgreSegment.h:76
Vector3 mOrigin
Definition: OgreSegment.h:75
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
void setEndPoint(const Vector3 &newEndpoint)