Apollo 10.0
自动驾驶开放平台
linear_interpolation.h
浏览该文件的文档.
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_msgs/basic_msgs/pnc_point.pb.h"
28
33namespace apollo {
34namespace common {
35namespace math {
36
47template <typename T>
48T 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
70double slerp(const double a0, const double t0, const double a1, const double t1,
71 const double t);
72
73SLPoint InterpolateUsingLinearApproximation(const SLPoint &p0,
74 const SLPoint &p1, const double w);
75
76PathPoint InterpolateUsingLinearApproximation(const PathPoint &p0,
77 const PathPoint &p1,
78 const double s);
79
80TrajectoryPoint InterpolateUsingLinearApproximation(const TrajectoryPoint &tp0,
81 const TrajectoryPoint &tp1,
82 const double t);
83
84} // namespace math
85} // namespace common
86} // namespace apollo
#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.
double slerp(const double a0, const double t0, const double a1, const double t1, const double t)
Spherical linear interpolation between two angles.
class register implement
Definition arena_queue.h:37