InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
PMLine.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Jeff Argast
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //
23 // Your basic line class. Encapsulates the equation for a line,
24 // solves for x, solves for y, and handles intersection testing.
25 //
26 //========================================================================================
27 
28 #ifndef __PMLine__
29 #define __PMLine__
30 
31  class PMPoint;
32 
33 
36 class PMLine
37  {
38  public:
39 
42  PMLine();
43 
48  PMLine (const PMReal& slope, const PMReal& yIntercept);
49 
54  PMLine (const PMReal& xIntercept);
55 
61  PMLine (const PMPoint& P1, const PMPoint& P2);
62 
68  bool16 SolveForY (const PMReal& X, PMReal* Y) const;
69 
75  bool16 SolveForX (const PMReal& Y, PMReal* X) const;
76 
82  PMLine SolveForPerpendicularLine (const PMPoint& P) const;
83 
92  bool16 SolveForIntersectPoint (const PMLine& otherLine, PMPoint* intersectPt) const;
93 
101  bool16 SolveForIntersectPoint (const PMPoint& P1, const PMPoint& P2, PMPoint* intersectPt) const;
102 
107  bool16 GetSlope (PMReal* pSlope) const;
108 
118  bool16 FindPointOnLine (const PMPoint& P0, const PMReal& dist, const PMPoint& refPoint, PMPoint* retPt) const;
119 
124  bool16 ContainsPoint(const PMPoint& point) const;
125 
126  // Comparison operator
132  friend bool16 operator ==(const PMLine& a, const PMLine& b);
138  friend bool16 operator !=(const PMLine& a, const PMLine& b);
139 
140 private:
141  PMReal fSlope;
142  PMReal fYIntercept;
143  PMReal fXIntercept;
144  bool16 fSlopeIsInfinite;
145  bool16 fUndefined; // for those rare cases when the line can't be solved for
146 };
147 
148 
149 #endif
150