configuration.cpp
Go to the documentation of this file.
1 /*********************************************************************
2 * Copyright (c) 2017 - for information on the respective copyright
3 * owner see the NOTICE file and/or the repository
4 *
5 * https://github.com/hbanzhaf/steering_functions.git
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
16 * implied. See the License for the specific language governing
17 * permissions and limitations under the License.
18 
19 * This source code is derived from Continuous Curvature (CC) Steer.
20 * Copyright (c) 2016, Thierry Fraichard and Institut national de
21 * recherche en informatique et en automatique (Inria), licensed under
22 * the BSD license, cf. 3rd-party-licenses.txt file in the root
23 * directory of this source tree.
24 **********************************************************************/
25 
26 #include <cmath>
27 #include <iostream>
28 
31 
32 using namespace std;
33 
34 namespace steering
35 {
36 
37 Configuration::Configuration(double _x, double _y, double _theta, double _kappa)
38 {
39  x = _x;
40  y = _y;
41  theta = twopify(_theta);
42  kappa = _kappa;
43 }
44 
45 void Configuration::print(bool eol) const
46 {
47  cout << "(" << x << ", " << y << ", " << theta << ", " << kappa << ")";
48  if (eol)
49  {
50  cout << endl;
51  }
52 }
53 
55 {
56  return point_distance(q1.x, q1.y, q2.x, q2.y);
57 }
58 
60 {
61  if (fabs(q2.theta - q1.theta) > get_epsilon())
62  {
63  return false;
64  }
65  double angle = twopify(atan2(q2.y - q1.y, q2.x - q1.x));
66  return fabs(angle - q1.theta) <= get_epsilon();
67 }
68 
70 {
71  if (fabs(q2.theta - q1.theta) > get_epsilon())
72  return false;
73  if (configuration_distance(q1, q2) > get_epsilon())
74  return false;
75  return true;
76 }
77 
78 } // namespace steering
steering::point_distance
double point_distance(double x1, double y1, double x2, double y2)
Cartesian distance between two points.
Definition: utilities.cpp:67
angle
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
configuration.hpp
steering::configuration_distance
double configuration_distance(const Configuration &q1, const Configuration &q2)
Cartesian distance between two configurations.
Definition: configuration.cpp:54
steering::Configuration
Definition: configuration.hpp:55
steering::get_epsilon
double get_epsilon()
Return value of epsilon.
Definition: utilities.cpp:57
std
plot_states.kappa
kappa
Definition: plot_states.py:106
steering
Definition: dubins_state_space.hpp:70
steering::configuration_aligned
bool configuration_aligned(const Configuration &q1, const Configuration &q2)
Are two configurations aligned?
Definition: configuration.cpp:59
steering::configuration_equal
bool configuration_equal(const Configuration &q1, const Configuration &q2)
Are two configurations equal?
Definition: configuration.cpp:69
steering::Configuration::y
double y
Definition: configuration.hpp:88
steering::twopify
double twopify(double alpha)
Conversion of arbitrary angle given in [rad] to [0, 2*pi[.
Definition: utilities.cpp:78
steering::Configuration::x
double x
Position.
Definition: configuration.hpp:88
utilities.hpp
steering::Configuration::theta
double theta
Orientation in rad between [0, 2*pi[.
Definition: configuration.hpp:91


steering_functions
Author(s): Holger Banzhaf
autogenerated on Mon Dec 11 2023 03:27:43