summaryrefslogtreecommitdiff
path: root/inc/gp_Lin.lxx
blob: 2c1e52316ac96ee0736d6ca098ec6d6538dd493b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// File gp_Lin.lxx ,  JCV 03/06/90
// JCV 30/08/90 Modif passage version C++ 2.0 sur Sun

inline gp_Lin::gp_Lin ()
{ }

inline gp_Lin::gp_Lin (const gp_Ax1& A1) : pos (A1)
{ }

inline gp_Lin::gp_Lin (const gp_Pnt& P,
		       const gp_Dir& V) : pos (P, V)
{ }

inline void gp_Lin::Reverse()
{ pos.Reverse(); }

inline gp_Lin gp_Lin::Reversed() const { 
  gp_Lin L = *this;
  L.pos.Reverse();
  return L;
}

inline void gp_Lin::SetDirection (const gp_Dir& V)
{ pos.SetDirection(V); }

inline void gp_Lin::SetLocation (const gp_Pnt& P)
{ pos.SetLocation(P); }

inline void gp_Lin::SetPosition (const gp_Ax1& A1)
{ pos = A1; }

inline const gp_Dir& gp_Lin::Direction() const
{ return pos.Direction(); }

inline const gp_Pnt& gp_Lin::Location()  const
{ return pos.Location(); }

inline    const gp_Ax1& gp_Lin::Position() const
{ return pos; }

inline Standard_Real gp_Lin::Angle (const gp_Lin& Other) const
{ return pos.Direction().Angle (Other.pos.Direction()); }

inline Standard_Boolean gp_Lin::Contains
(const gp_Pnt& P,
 const Standard_Real LinearTolerance) const
{ return Distance(P) <= LinearTolerance; }

inline Standard_Real gp_Lin::Distance (const gp_Pnt& P) const {
  gp_XYZ Coord = P.XYZ();
  Coord.Subtract ((pos.Location()).XYZ());
  Coord.Cross ((pos.Direction()).XYZ());
  return Coord.Modulus();
}

inline Standard_Real gp_Lin::SquareDistance (const gp_Pnt& P) const
{
  const gp_Pnt& Loc = pos.Location();
  gp_Vec V (P.X() - Loc.X(),
	    P.Y() - Loc.Y(),
	    P.Z() - Loc.Z());
  V.Cross (pos.Direction());
  return V.SquareMagnitude ();                                          
}

inline Standard_Real gp_Lin::SquareDistance (const gp_Lin& Other) const
{
  Standard_Real D = Distance (Other);
  return D * D;
}

inline gp_Lin gp_Lin::Normal (const gp_Pnt& P) const
{
  const gp_Pnt& Loc = pos.Location();
  gp_Dir V (P.X() - Loc.X(),
	    P.Y() - Loc.Y(),
	    P.Z() - Loc.Z());
  V = pos.Direction().CrossCrossed(V, pos.Direction());
  return gp_Lin (P, V);
}

inline void gp_Lin::Rotate (const gp_Ax1& A1,
			    const Standard_Real Ang)
{ pos.Rotate(A1, Ang); }

inline gp_Lin gp_Lin::Rotated (const gp_Ax1& A1,
			       const Standard_Real Ang) const
{
  gp_Lin L = *this;
  L.pos.Rotate (A1, Ang);
  return L;
}

inline void gp_Lin::Scale (const gp_Pnt& P,
			   const Standard_Real S)
{ pos.Scale(P, S); }

inline gp_Lin gp_Lin::Scaled (const gp_Pnt& P,
			      const Standard_Real S) const
{
  gp_Lin L = *this;
  L.pos.Scale (P, S);
  return L;
}

inline void gp_Lin::Transform (const gp_Trsf& T)
{ pos.Transform(T); }

inline gp_Lin gp_Lin::Transformed (const gp_Trsf& T) const
{
  gp_Lin L = *this;
  L.pos.Transform (T);
  return L;
}

inline void gp_Lin::Translate (const gp_Vec& V)
{ pos.Translate(V); }

inline gp_Lin gp_Lin::Translated (const gp_Vec& V) const
{
  gp_Lin L = *this;
  L.pos.Translate (V); 
  return L;
}

inline void gp_Lin::Translate (const gp_Pnt& P1,
			       const gp_Pnt& P2)
{pos.Translate (P1, P2);}

inline gp_Lin gp_Lin::Translated (const gp_Pnt& P1,
				  const gp_Pnt& P2) const
{
  gp_Lin L = *this;
  L.pos.Translate (gp_Vec(P1, P2));
  return L;
}