Apollo
11.0
自动驾驶开放平台
target_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
17
#include "
modules/tools/visualizer/target_camera.h
"
18
19
TargetCamera::TargetCamera
()
20
:
AbstractCamera
(), target_pos_(0.0, 0.0, 0.0), distance_(10.0) {}
21
22
void
TargetCamera::UpdateWorld
() {
23
QMatrix4x4 R =
YawPitchRoll
(
yaw
(),
pitch
(),
roll
());
24
QVector3D T{0, 0, distance_};
25
T = QVector3D(R * QVector4D(T, 0.0f));
26
position_
= target_pos_ + T;
27
look_
= target_pos_ -
position_
;
28
look_
.normalize();
29
30
up_
= QVector3D(R * QVector4D(
UP
, 0.0f));
31
right_
= QVector3D::crossProduct(
look_
,
up_
);
32
33
model_view_mat_
.setToIdentity();
34
model_view_mat_
.lookAt(
position_
, target_pos_,
up_
);
35
}
AbstractCamera
Definition
abstract_camera.h:21
AbstractCamera::roll
float roll(void) const
Definition
abstract_camera.h:98
AbstractCamera::look_
QVector3D look_
Definition
abstract_camera.h:143
AbstractCamera::model_view_mat_
QMatrix4x4 model_view_mat_
Definition
abstract_camera.h:148
AbstractCamera::YawPitchRoll
static QMatrix4x4 YawPitchRoll(float yawInDegrees, float picthInDegrees, float rollInDegrees)
Definition
abstract_camera.cc:22
AbstractCamera::right_
QVector3D right_
Definition
abstract_camera.h:145
AbstractCamera::pitch
float pitch(void) const
Definition
abstract_camera.h:95
AbstractCamera::position_
QVector3D position_
Definition
abstract_camera.h:140
AbstractCamera::up_
QVector3D up_
Definition
abstract_camera.h:144
AbstractCamera::UP
static const QVector3D UP
Definition
abstract_camera.h:20
AbstractCamera::yaw
float yaw(void) const
Definition
abstract_camera.h:92
TargetCamera::TargetCamera
TargetCamera()
Definition
target_camera.cc:19
TargetCamera::UpdateWorld
virtual void UpdateWorld()
Definition
target_camera.cc:22
target_camera.h
modules
tools
visualizer
target_camera.cc