summaryrefslogtreecommitdiff
path: root/inc/gp_Parab.lxx
blob: 7f625dc7a78b440fae19f6adb57f86b47664e473 (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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
//File gp_Parab.lxx JCV/12/10/90

#include <gp_Lin.hxx>
#include <Standard_ConstructionError.hxx>

inline gp_Parab::gp_Parab () :
focalLength (RealLast())
{ }

inline gp_Parab::gp_Parab (const gp_Ax2& A2,
			   const Standard_Real Focal) :
			   pos(A2),
			   focalLength (Focal)
{ Standard_ConstructionError_Raise_if(Focal < 0.0,""); }

inline gp_Parab::gp_Parab (const gp_Ax1& D,
			   const gp_Pnt& F)
{
  gp_Lin Droite(D);
  focalLength = Droite.Distance(F) / 2.;
  gp_Ax1 Ax = Droite.Normal(F).Position();
  gp_Ax1 Ay = Droite.Position();     
  const gp_Dir& DD = Ax.Direction();
  pos = gp_Ax2 (gp_Pnt(F.X() - focalLength * DD.X(),
		       F.Y() - focalLength * DD.Y(),
		       F.Z() - focalLength * DD.Z()),
		Ax.Direction().Crossed(Ay.Direction()),
		Ax.Direction());
}

inline void gp_Parab::SetAxis (const gp_Ax1& A1)
{ pos.SetAxis (A1); }

inline void gp_Parab::SetFocal (const Standard_Real Focal)
{ 
  Standard_ConstructionError_Raise_if(Focal < 0.0,"");
  focalLength = Focal;
}

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

inline void gp_Parab::SetPosition (const gp_Ax2& A2)
{ pos = A2; }

inline const gp_Ax1& gp_Parab::Axis ()     const
{ return pos.Axis(); }

inline gp_Ax1 gp_Parab::Directrix() const
{
  const gp_Pnt& PP = pos.Location  ();
  const gp_Dir& DD = pos.XDirection();
  gp_Pnt P (PP.X() - focalLength * DD.X(),
	    PP.Y() - focalLength * DD.Y(),
	    PP.Z() - focalLength * DD.Z());
  return gp_Ax1 (P, pos.YDirection());
}

inline   Standard_Real gp_Parab::Focal() const
{ return focalLength; }

inline gp_Pnt gp_Parab::Focus() const
{
  const gp_Pnt& PP = pos.Location  ();
  const gp_Dir& DD = pos.XDirection();
  return gp_Pnt (PP.X() + focalLength * DD.X(),
		 PP.Y() + focalLength * DD.Y(),
		 PP.Z() + focalLength * DD.Z());
}

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

inline Standard_Real gp_Parab::Parameter() const
{ return 2.0 * focalLength; }

inline   const gp_Ax2& gp_Parab::Position() const
{ return pos; }

inline gp_Ax1 gp_Parab::XAxis () const
{ return gp_Ax1 (pos.Location(), pos.XDirection()); }

inline gp_Ax1 gp_Parab::YAxis () const
{ return gp_Ax1 (pos.Location(), pos.YDirection()); }

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

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

inline void gp_Parab::Scale (const gp_Pnt& P,
			     const Standard_Real S)
{
  focalLength *= S;
  if (focalLength < 0) focalLength = - focalLength;
  pos.Scale (P, S);
}

inline gp_Parab gp_Parab::Scaled (const gp_Pnt& P,
				  const Standard_Real S) const
{
  gp_Parab Prb = *this;
  Prb.focalLength *= S;
  if (Prb.focalLength < 0) Prb.focalLength = - Prb.focalLength;
  Prb.pos.Scale (P, S);
  return Prb;     
}

inline void gp_Parab::Transform (const gp_Trsf& T)
{ 
  focalLength *= T.ScaleFactor();
  if (focalLength < 0) focalLength = - focalLength;
  pos.Transform (T); 
}

inline gp_Parab gp_Parab::Transformed (const gp_Trsf& T) const
{
  gp_Parab Prb = *this;
  Prb.focalLength *= T.ScaleFactor();
  if (Prb.focalLength < 0) Prb.focalLength = - Prb.focalLength;
  Prb.pos.Transform (T);
  return Prb;     
}

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

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

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

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