Welcome to mirror list, hosted at ThFree Co, Russian Federation.

look_at.cpp « igl « libigl « src - github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c55c9b2ec56ebf87126a3c5265468e1cc7ee0d89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// This file is part of libigl, a simple c++ geometry processing library.
// 
// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
// 
// This Source Code Form is subject to the terms of the Mozilla Public License 
// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
// obtain one at http://mozilla.org/MPL/2.0/.
#include "look_at.h"

template <
  typename Derivedeye,
  typename Derivedcenter,
  typename Derivedup,
  typename DerivedR>
IGL_INLINE void igl::look_at(
  const Eigen::PlainObjectBase<Derivedeye> & eye,
  const Eigen::PlainObjectBase<Derivedcenter> & center,
  const Eigen::PlainObjectBase<Derivedup> & up,
  Eigen::PlainObjectBase<DerivedR> & R)
{
  typedef Eigen::Matrix<typename DerivedR::Scalar,3,1> Vector3S;
  Vector3S f = (center - eye).normalized();
  Vector3S s = f.cross(up).normalized();
  Vector3S u = s.cross(f);
  R = Eigen::Matrix<typename DerivedR::Scalar,4,4>::Identity();
  R(0,0) = s(0);
  R(0,1) = s(1);
  R(0,2) = s(2);
  R(1,0) = u(0);
  R(1,1) = u(1);
  R(1,2) = u(2);
  R(2,0) =-f(0);
  R(2,1) =-f(1);
  R(2,2) =-f(2);
  R(0,3) =-s.transpose() * eye;
  R(1,3) =-u.transpose() * eye;
  R(2,3) = f.transpose() * eye;
}

#ifdef IGL_STATIC_LIBRARY
// Explicit template instantiation
// generated by autoexplicit.sh
template void igl::look_at<Eigen::Matrix<float, 3, 1, 0, 3, 1>, Eigen::Matrix<float, 3, 1, 0, 3, 1>, Eigen::Matrix<float, 3, 1, 0, 3, 1>, Eigen::Matrix<float, 4, 4, 0, 4, 4> >(Eigen::PlainObjectBase<Eigen::Matrix<float, 3, 1, 0, 3, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, 3, 1, 0, 3, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, 3, 1, 0, 3, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, 4, 4, 0, 4, 4> >&);
#endif