Debian Codegraph @

src/gen/lib/pathplan/solvers__c.java

raw symbols SCIP
1 /* ========================================================================
2 * PlantUML : a free UML diagram generator
3 * ========================================================================
4 *
5 * Project Info: http://plantuml.com
6 *
7 * If you like this project or if you find it useful, you can support us at:
8 *
9 * http://plantuml.com/patreon (only 1$ per month!)
10 * http://plantuml.com/paypal
11 *
12 * This file is part of Smetana.
13 * Smetana is a partial translation of Graphviz/Dot sources from C to Java.
14 *
15 * (C) Copyright 2009-2020, Arnaud Roques
16 *
17 * This translation is distributed under the same Licence as the original C program:
18 *
19 *************************************************************************
20 * Copyright (c) 2011 AT&T Intellectual Property
21 * All rights reserved. This program and the accompanying materials
22 * are made available under the terms of the Eclipse Public License v1.0
23 * which accompanies this distribution, and is available at
24 * http://www.eclipse.org/legal/epl-v10.html
25 *
26 * Contributors: See CVS logs. Details at http://www.graphviz.org/
27 *************************************************************************
28 *
29 * THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
30 * LICENSE ("AGREEMENT"). [Eclipse Public License - v 1.0]
31 *
32 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES
33 * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
34 *
35 * You may obtain a copy of the License at
36 *
37 * http://www.eclipse.org/legal/epl-v10.html
38 *
39 * Unless required by applicable law or agreed to in writing, software
40 * distributed under the License is distributed on an "AS IS" BASIS,
41 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42 * See the License for the specific language governing permissions and
43 * limitations under the License.
44 *
45 */
46 package gen.lib.pathplan;
47 import static smetana.core.JUtils.atan2;
48 import static smetana.core.JUtils.cos;
49 import static smetana.core.JUtils.pow;
50 import static smetana.core.JUtils.sqrt;
51 import static smetana.core.JUtilsDebug.ENTERING;
52 import static smetana.core.JUtilsDebug.LEAVING;
53
54 public class solvers__c {
55
56
57 //3 2rap7a11ad4ugnphkh9gbn4xl
58 // int solve3(double *coeff, double *roots)
59 public static int solve3(double coeff[], double roots[]) {
60 ENTERING("2rap7a11ad4ugnphkh9gbn4xl","solve3");
61 try {
62 double a, b, c, d;
63 int rootn, i;
64 double p, q, disc, b_over_3a, c_over_a, d_over_a;
65 double r, theta, temp, alpha, beta;
66 a = coeff[3]; b = coeff[2]; c = coeff[1]; d = coeff[0];
67 if ((((a) < 1E-7) && ((a) > -1E-7)))
68 return solve2(coeff, roots);
69 b_over_3a = b / (3 * a);
70 c_over_a = c / a;
71 d_over_a = d / a;
72 p = b_over_3a * b_over_3a;
73 q = 2 * b_over_3a * p - b_over_3a * c_over_a + d_over_a;
74 p = c_over_a / 3 - p;
75 disc = q * q + 4 * p * p * p;
76 if (disc < 0) {
77 r = .5 * sqrt(-disc + q * q);
78 theta = atan2(sqrt(-disc), -q);
79 temp = 2 * ((r < 0) ? (-1*pow(-r, 1.0/3.0)) : pow (r, 1.0/3.0));
80 roots[0] = temp * cos(theta / 3);
81 roots[1] = temp * cos((theta + 3.14159265358979323846 + 3.14159265358979323846) / 3);
82 roots[2] = temp * cos((theta - 3.14159265358979323846 - 3.14159265358979323846) / 3);
83 rootn = 3;
84 } else {
85 alpha = .5 * (sqrt(disc) - q);
86 beta = -q - alpha;
87 roots[0] = ((alpha < 0) ? (-1*pow(-alpha, 1.0/3.0)) : pow (alpha, 1.0/3.0)) + ((beta < 0) ? (-1*pow(-beta, 1.0/3.0)) : pow (beta, 1.0/3.0));
88 if (disc > 0)
89 rootn = 1;
90 else
91 {roots[1] = roots[2] = -.5 * roots[0]; rootn = 3;}
92 }
93 for (i = 0; i < rootn; i++)
94 roots[i] -= b_over_3a;
95 return rootn;
96 } finally {
97 LEAVING("2rap7a11ad4ugnphkh9gbn4xl","solve3");
98 }
99 }
100
101
102
103
104 //3 9b5238tdddphds1x726z0osdm
105 // int solve2(double *coeff, double *roots)
106 public static int solve2(double coeff[], double roots[]) {
107 ENTERING("9b5238tdddphds1x726z0osdm","solve2");
108 try {
109 double a, b, c;
110 double disc, b_over_2a, c_over_a;
111 a = coeff[2]; b = coeff[1]; c = coeff[0];
112 if ((((a) < 1E-7) && ((a) > -1E-7)))
113 return solve1(coeff, roots);
114 b_over_2a = b / (2 * a);
115 c_over_a = c / a;
116 disc = b_over_2a * b_over_2a - c_over_a;
117 if (disc < 0)
118 return 0;
119 else if (disc == 0) {
120 roots[0] = -b_over_2a;
121 return 1;
122 } else {
123 roots[0] = -b_over_2a + sqrt(disc);
124 roots[1] = -2 * b_over_2a - roots[0];
125 return 2;
126 }
127 } finally {
128 LEAVING("9b5238tdddphds1x726z0osdm","solve2");
129 }
130 }
131
132
133
134
135 //3 8xtqt7j6wyxc1b6tj0qtcu1rd
136 // int solve1(double *coeff, double *roots)
137 public static int solve1(double coeff[], double roots[]) {
138 ENTERING("8xtqt7j6wyxc1b6tj0qtcu1rd","solve1");
139 try {
140 double a, b;
141 a = coeff[1]; b = coeff[0];
142 if ((((a) < 1E-7) && ((a) > -1E-7))) {
143 if ((((b) < 1E-7) && ((b) > -1E-7)))
144 return 4;
145 else
146 return 0;
147 }
148 roots[0] = -b / a;
149 return 1;
150 } finally {
151 LEAVING("8xtqt7j6wyxc1b6tj0qtcu1rd","solve1");
152 }
153 }
154
155
156 }