summaryrefslogtreecommitdiff
path: root/inc/GccIter_FunctionTanCuPnt.gxx
blob: d1233da7583bad7d74871438b0924969725398bd (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
// File:	GccIter_FunctionTanCuPnt.gxx
// Created:	Mon Jan 20 16:35:40 1992
// Author:	Remi GILET
//		<reg@phobox>

#include <gp_Vec2d.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Vec.hxx>
#include <gp_Pnt.hxx>

//=========================================================================
//  soit P1 le point sur la courbe TheCurve d abscisse u.                 +
//  soit C  le point ThePoint.                                            +
//  Nous cherchons donc les zeros de la fonction suivante:                +
//                                                                        +
//                 -->   -->                                              +
//                 CP1 /\ T                                               +
//             ---------------  =  F(u)                                   +
//             ||CP1|| * ||T||                                            +
//                                                                        +
//  La derivee de cette fonction est :                                    +
//            CP1 /\ N        (T.N)*((CP1/\T).((CP1/\T))                  +
//     f(u) = --------  -  --------------------------------               +
//               N.N            N*N*N*CP1*CP1*CP1                         +
//=========================================================================

GccIter_FunctionTanCuPnt::
  GccIter_FunctionTanCuPnt(const TheCurve& C      ,
			     const gp_Pnt2d& Point  ) {
  TheCurv = C;
  ThePoint = Point;
 }


Standard_Boolean GccIter_FunctionTanCuPnt::
  Value (const Standard_Real  X    ,
	       Standard_Real& Fval ) {
  gp_Pnt2d Point;
  gp_Vec2d Vect;
  TheCurveTool::D1(TheCurv,X,Point,Vect);
  Standard_Real NormeD1 = Vect.Magnitude();
  gp_Vec2d TheDirection(ThePoint,Point);
  Standard_Real NormeDir = TheDirection.Magnitude();
  Fval = TheDirection.Crossed(Vect)/(NormeD1*NormeDir);
  return Standard_True;
}

Standard_Boolean GccIter_FunctionTanCuPnt::
  Derivative (const Standard_Real  X     ,
	            Standard_Real& Deriv ) {
  gp_Pnt2d Point;
  gp_Vec2d Vec1;
  gp_Vec2d Vec2;
  TheCurveTool::D2(TheCurv,X,Point,Vec1,Vec2);
  gp_Vec2d TheDirection(ThePoint.XY(),gp_XY(Point.XY()));
  Standard_Real NormeD1 = Vec1.Magnitude();
  Standard_Real NormeDir = TheDirection.Magnitude();
  Deriv = TheDirection.Crossed(Vec2)/(NormeD1*NormeDir)-
    (TheDirection.Crossed(Vec1)/(NormeD1*NormeDir))*
      (Vec1.Dot(Vec2)/(NormeD1*NormeD1)+
       Vec1.Dot(TheDirection)/(NormeDir*NormeDir));
  return Standard_True;
}

Standard_Boolean GccIter_FunctionTanCuPnt::
  Values (const Standard_Real  X     ,
	        Standard_Real& Fval  ,
	        Standard_Real& Deriv ) {
  gp_Pnt2d Point;
  gp_Vec2d Vec1;
  gp_Vec2d Vec2;
  TheCurveTool::D2(TheCurv,X,Point,Vec1,Vec2);
  gp_Vec2d TheDirection(ThePoint.XY(),gp_XY(Point.XY()));
  Standard_Real NormeD1 = Vec1.Magnitude();
  Standard_Real NormeDir = TheDirection.Magnitude();
  Fval = TheDirection.Crossed(Vec1)/(NormeD1*NormeDir);
  Deriv = TheDirection.Crossed(Vec2)/(NormeD1*NormeDir)-
    (TheDirection.Crossed(Vec1)/(NormeD1*NormeDir))*
      (Vec1.Dot(Vec2)/(NormeD1*NormeD1)+
       Vec1.Dot(TheDirection)/(NormeDir*NormeDir));

//  cout  << "U = "<< X << " F ="<< Fval <<" DF ="<< Deriv<<endl;

  return Standard_True;
}