diff options
Diffstat (limited to 'linden/indra/llmath/llline.h')
-rw-r--r-- | linden/indra/llmath/llline.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/linden/indra/llmath/llline.h b/linden/indra/llmath/llline.h new file mode 100644 index 0000000..ca454c5 --- /dev/null +++ b/linden/indra/llmath/llline.h | |||
@@ -0,0 +1,75 @@ | |||
1 | // llline.h | ||
2 | /** | ||
3 | * @file llline.cpp | ||
4 | * @author Andrew Meadows | ||
5 | * @brief Simple line for computing nearest approach between two infinite lines | ||
6 | * | ||
7 | * $LicenseInfo:firstyear=2006&license=internal$ | ||
8 | * | ||
9 | * Copyright (c) 2006-2008, Linden Research, Inc. | ||
10 | * | ||
11 | * The following source code is PROPRIETARY AND CONFIDENTIAL. Use of | ||
12 | * this source code is governed by the Linden Lab Source Code Disclosure | ||
13 | * Agreement ("Agreement") previously entered between you and Linden | ||
14 | * Lab. By accessing, using, copying, modifying or distributing this | ||
15 | * software, you acknowledge that you have been informed of your | ||
16 | * obligations under the Agreement and agree to abide by those obligations. | ||
17 | * | ||
18 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
19 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
20 | * COMPLETENESS OR PERFORMANCE. | ||
21 | * $/LicenseInfo$ | ||
22 | */ | ||
23 | |||
24 | #ifndef LL_LINE_H | ||
25 | #define LL_LINE_H | ||
26 | |||
27 | #include <iostream> | ||
28 | #include "stdtypes.h" | ||
29 | #include "v3math.h" | ||
30 | |||
31 | const F32 DEFAULT_INTERSECTION_ERROR = 0.000001f; | ||
32 | |||
33 | class LLLine | ||
34 | { | ||
35 | public: | ||
36 | LLLine(); | ||
37 | LLLine( const LLVector3& first_point, const LLVector3& second_point ); | ||
38 | virtual ~LLLine() {}; | ||
39 | |||
40 | void setPointDirection( const LLVector3& first_point, const LLVector3& second_point ); | ||
41 | void setPoints( const LLVector3& first_point, const LLVector3& second_point ); | ||
42 | |||
43 | bool intersects( const LLVector3& point, F32 radius = DEFAULT_INTERSECTION_ERROR ) const; | ||
44 | |||
45 | // returns the point on this line that is closest to some_point | ||
46 | LLVector3 nearestApproach( const LLVector3& some_point ) const; | ||
47 | |||
48 | // returns the point on this line that is closest to other_line | ||
49 | LLVector3 nearestApproach( const LLLine& other_line ) const; | ||
50 | |||
51 | friend std::ostream& operator<<( std::ostream& output_stream, const LLLine& line ); | ||
52 | |||
53 | // returns 'true' if this line intersects the plane | ||
54 | // on success stores the intersection point in 'result' | ||
55 | bool intersectsPlane( LLVector3& result, const LLLine& plane ) const; | ||
56 | |||
57 | // returns 'true' if planes intersect, and stores the result | ||
58 | // the second and third arguments are treated as planes | ||
59 | // where mPoint is on the plane and mDirection is the normal | ||
60 | // result.mPoint will be the intersection line's closest approach | ||
61 | // to first_plane.mPoint | ||
62 | static bool getIntersectionBetweenTwoPlanes( LLLine& result, const LLLine& first_plane, const LLLine& second_plane ); | ||
63 | |||
64 | const LLVector3& getPoint() const { return mPoint; } | ||
65 | const LLVector3& getDirection() const { return mDirection; } | ||
66 | |||
67 | protected: | ||
68 | // these are protected because some code assumes that the normal is | ||
69 | // always correct and properly normalized. | ||
70 | LLVector3 mPoint; | ||
71 | LLVector3 mDirection; | ||
72 | }; | ||
73 | |||
74 | |||
75 | #endif | ||