Apollo 11.0
自动驾驶开放平台
abstract_camera.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 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
18#include <cmath>
19
20const QVector3D AbstractCamera::UP{0.0f, 1.0f, 0.0f};
21
22QMatrix4x4 AbstractCamera::YawPitchRoll(float yaw, float pitch, float roll) {
23 yaw = Radians(yaw);
25 roll = Radians(roll);
26
27 register float tmpCy = std::cos(yaw);
28 register float tmpSy = std::sin(yaw);
29 register float tmpCp = std::cos(pitch);
30 register float tmpSp = std::sin(pitch);
31 register float tmpCr = std::cos(roll);
32 register float tmpSr = std::sin(roll);
33
34 QMatrix4x4 Result;
35 Result(0, 0) = tmpCy * tmpCr + tmpSy * tmpSp * tmpSr;
36 Result(1, 0) = tmpSr * tmpCp;
37 Result(2, 0) = -tmpSy * tmpCr + tmpCy * tmpSp * tmpSr;
38 Result(3, 0) = 0.0f;
39 Result(0, 1) = -tmpCy * tmpSr + tmpSy * tmpSp * tmpCr;
40 Result(1, 1) = tmpCr * tmpCp;
41 Result(2, 1) = tmpSr * tmpSy + tmpCy * tmpSp * tmpCr;
42 Result(3, 1) = 0.0f;
43 Result(0, 2) = tmpSy * tmpCp;
44 Result(1, 2) = -tmpSp;
45 Result(2, 2) = tmpCy * tmpCp;
46 Result(3, 2) = 0.0f;
47 Result(0, 3) = 0.0f;
48 Result(1, 3) = 0.0f;
49 Result(2, 3) = 0.0f;
50 Result(3, 3) = 1.0f;
51 return Result;
52}
53
55 : camera_mode_(CameraMode::PerspectiveMode),
56 fov_(45.0f),
57 near_plane_width_(1.0f),
58 near_plane_height_(1.0f),
59 near_plane_(0.1f),
60 far_plane_(1000.0f),
61 position_(0.0f, 0.0f, 0.0f),
62 attitude_(),
63 look_(0.0f, 0.0f, 1.0f),
64 up_(UP),
65 right_(1.0f, 0.0f, 0.0f),
66 projection_mat_(),
67 model_view_mat_() {}
float roll(void) const
static QMatrix4x4 YawPitchRoll(float yawInDegrees, float picthInDegrees, float rollInDegrees)
float pitch(void) const
static const QVector3D UP
static float Radians(float degrees)
float yaw(void) const