1 /* Siconos is a program dedicated to modeling, simulation and control
2  * of non smooth dynamical systems.
3  *
4  * Copyright 2021 INRIA.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17 */
18 #include <math.h>
19 #include "projectionOnCylinder.h"
20 
projectionOnCylinder(double * r,double R)21 void projectionOnCylinder(double* r, double  R)
22 {
23 
24   double normTsquare = r[1] * r[1] + r[2] * r[2];
25 
26   if(r[0] >= 0)
27   {
28     if(normTsquare <= R * R)
29     {
30       return ;
31     }
32     else
33     {
34       normTsquare = sqrt(normTsquare);
35       r[1] = R * r[1] / normTsquare;
36       r[2] = R * r[2] / normTsquare;
37       return;
38     }
39   }
40   else
41   {
42     r[0] = 0.0;
43     if(0 < normTsquare)
44     {
45 
46       normTsquare = sqrt(normTsquare);
47       r[1] = R * r[1] / normTsquare;
48       r[2] = R * r[2] / normTsquare;
49       /*    r[1]=0.0; */
50       /*    r[2]=0.0; */
51       return;
52     }
53     else
54     {
55       r[1] = 0.0;
56       r[2] = 0.0;
57       return;
58     }
59 
60   }
61 }
projectionOnGeneralCylinder(double * r,double R,int dim)62 void projectionOnGeneralCylinder(double* r, double  R, int dim)
63 {
64 
65 }
66