summaryrefslogtreecommitdiff
path: root/inc/gp_Parab2d.lxx
blob: de73e4a416aa18e8fadab8725335fbb88626427f (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
154
//File gp_Parab2d.lxx

#include <Standard_ConstructionError.hxx>

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

inline gp_Parab2d::gp_Parab2d (const gp_Ax22d& A, 
			       const Standard_Real Focal) :
			       pos (A), 
			       focalLength (Focal) 
{ Standard_ConstructionError_Raise_if(Focal < 0.0,""); }

inline gp_Parab2d::gp_Parab2d (const gp_Ax2d& MirrorAxis, 
			       const Standard_Real Focal,
			       const Standard_Boolean Sense) :
			       focalLength (Focal) 
{
  pos = gp_Ax22d(MirrorAxis,Sense);
  Standard_ConstructionError_Raise_if(Focal < 0.0,"");
}

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

inline void gp_Parab2d::SetLocation   (const gp_Pnt2d& P)
{ pos.SetLocation(P); }

inline void gp_Parab2d::SetMirrorAxis (const gp_Ax2d& A)
{ pos.SetXAxis(A); }

inline void gp_Parab2d::SetAxis (const gp_Ax22d& A)
{ pos.SetAxis(A); }

inline gp_Ax2d gp_Parab2d::Directrix() const
{
  gp_Pnt2d P (pos.Location().X() - focalLength * pos.XDirection().X(),
	      pos.Location().Y() - focalLength * pos.XDirection().Y() );
  gp_Dir2d V (pos.YDirection().Reversed());
  return gp_Ax2d (P, V);
}

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

inline gp_Pnt2d gp_Parab2d::Focus() const
{
  return gp_Pnt2d (pos.Location().X() + focalLength * pos.XDirection().X(),
		   pos.Location().Y() + focalLength * pos.XDirection().Y());
}

inline gp_Pnt2d gp_Parab2d::Location () const
{ return pos.Location(); }

inline gp_Ax2d gp_Parab2d::MirrorAxis () const 
{ return pos.XAxis(); }

inline gp_Ax22d gp_Parab2d::Axis () const 
{ return pos; }

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

inline void gp_Parab2d::Reverse() 
{
  gp_Dir2d Temp = pos.YDirection ();
  Temp.Reverse ();
  pos.SetAxis(gp_Ax22d(pos.Location(),pos.XDirection(),Temp));
}

inline gp_Parab2d gp_Parab2d::Reversed() const
{
  gp_Parab2d P = *this;
  gp_Dir2d Temp = pos.YDirection ();
  Temp.Reverse ();
  P.pos.SetAxis(gp_Ax22d(pos.Location(),pos.XDirection(),Temp));
  return P;
}

inline Standard_Boolean gp_Parab2d::IsDirect() const
{ return (pos.XDirection().Crossed(pos.YDirection())) >= 0.0; }

inline void gp_Parab2d::Rotate (const gp_Pnt2d& P,
				const Standard_Real Ang)
{pos.Rotate (P, Ang);}

inline gp_Parab2d gp_Parab2d::Rotated (const gp_Pnt2d& P,
				       const Standard_Real Ang) const
{
  gp_Parab2d Prb = *this;
  Prb.pos.Rotate (P, Ang);
  return Prb;     
}

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

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

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

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

inline void gp_Parab2d::Translate (const gp_Vec2d& V)
{ pos.Translate (V); }

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

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

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