Apollo  6.0
Open source self driving car software
linear_interpolation.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2017 The Apollo Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 
22 #pragma once
23 
24 #include <cmath>
25 
26 #include "cyber/common/log.h"
27 #include "modules/common/proto/pnc_point.pb.h"
28 
33 namespace apollo {
34 namespace common {
35 namespace math {
36 
47 template <typename T>
48 T lerp(const T &x0, const double t0, const T &x1, const double t1,
49  const double t) {
50  if (std::abs(t1 - t0) <= 1.0e-6) {
51  AERROR << "input time difference is too small";
52  return x0;
53  }
54  const double r = (t - t0) / (t1 - t0);
55  const T x = x0 + r * (x1 - x0);
56  return x;
57 }
58 
70 double slerp(const double a0, const double t0, const double a1, const double t1,
71  const double t);
72 
73 SLPoint InterpolateUsingLinearApproximation(const SLPoint &p0,
74  const SLPoint &p1, const double w);
75 
76 PathPoint InterpolateUsingLinearApproximation(const PathPoint &p0,
77  const PathPoint &p1,
78  const double s);
79 
80 TrajectoryPoint InterpolateUsingLinearApproximation(const TrajectoryPoint &tp0,
81  const TrajectoryPoint &tp1,
82  const double t);
83 
84 } // namespace math
85 } // namespace common
86 } // namespace apollo
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
SLPoint InterpolateUsingLinearApproximation(const SLPoint &p0, const SLPoint &p1, const double w)
T abs(const T &x)
Definition: misc.h:48
double slerp(const double a0, const double t0, const double a1, const double t1, const double t)
Spherical linear interpolation between two angles. The two angles are within range [-M_PI...
#define AERROR
Definition: log.h:44
T lerp(const T &x0, const double t0, const T &x1, const double t1, const double t)
Linear interpolation between two points of type T.
Definition: linear_interpolation.h:48