OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * ***** BEGIN GPL LICENSE BLOCK ***** |
| 3 * |
| 4 * This program is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU General Public License |
| 6 * as published by the Free Software Foundation; either version 2 |
| 7 * of the License, or (at your option) any later version. |
| 8 * |
| 9 * This program is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 14 * You should have received a copy of the GNU General Public License |
| 15 * along with this program; if not, write to the Free Software Foundation, |
| 16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 * |
| 18 * This Code is Copyright (C) 2010 Blender Foundation. |
| 19 * All rights reserved. |
| 20 * |
| 21 * The Original Code is: |
| 22 * OGF/Graphite: Geometry and Graphics Programming Library + Utilities |
| 23 * Copyright (C) 2000 Bruno Levy |
| 24 * Contact: Bruno Levy |
| 25 * levy@loria.fr |
| 26 * ISA Project |
| 27 * LORIA, INRIA Lorraine,· |
| 28 * Campus Scientifique, BP 239 |
| 29 * 54506 VANDOEUVRE LES NANCY CEDEX· |
| 30 * FRANCE |
| 31 * |
| 32 * Contributor(s): none yet. |
| 33 * |
| 34 * ***** END GPL LICENSE BLOCK ***** |
| 35 */ |
| 36 |
| 37 /** \file blender/freestyle/intern/geometry/normal_cycle.cpp |
| 38 * \ingroup freestyle |
| 39 * \author Bruno Levy |
| 40 */ |
| 41 |
| 42 #include "matrix_util.h" |
| 43 #include "normal_cycle.h" |
| 44 |
| 45 namespace OGF { |
| 46 |
| 47 //_________________________________________________________ |
| 48 |
| 49 |
| 50 NormalCycle::NormalCycle() |
| 51 { |
| 52 } |
| 53 |
| 54 void NormalCycle::begin() |
| 55 { |
| 56 M_[0] = M_[1] = M_[2] = M_[3] = M_[4] = M_[5] = 0; |
| 57 } |
| 58 |
| 59 void NormalCycle::end() |
| 60 { |
| 61 double eigen_vectors[9]; |
| 62 MatrixUtil::semi_definite_symmetric_eigen(M_, 3, eigen_vectors, eigen_va
lue_); |
| 63 |
| 64 axis_[0] = Vec3r(eigen_vectors[0], eigen_vectors[1], eigen_vectors[2]); |
| 65 |
| 66 axis_[1] = Vec3r(eigen_vectors[3], eigen_vectors[4], eigen_vectors[5]); |
| 67 |
| 68 axis_[2] = Vec3r(eigen_vectors[6], eigen_vectors[7], eigen_vectors[8]); |
| 69 |
| 70 // Normalize the eigen vectors |
| 71 for (int i = 0; i < 3; i++) { |
| 72 axis_[i].normalize(); |
| 73 } |
| 74 |
| 75 // Sort the eigen vectors |
| 76 i_[0] = 0; |
| 77 i_[1] = 1; |
| 78 i_[2] = 2; |
| 79 |
| 80 double l0 = ::fabs(eigen_value_[0]); |
| 81 double l1 = ::fabs(eigen_value_[1]); |
| 82 double l2 = ::fabs(eigen_value_[2]); |
| 83 |
| 84 if (l1 > l0) { |
| 85 ogf_swap(l0 , l1 ); |
| 86 ogf_swap(i_[0], i_[1]); |
| 87 } |
| 88 if (l2 > l1) { |
| 89 ogf_swap(l1 , l2 ); |
| 90 ogf_swap(i_[1], i_[2]); |
| 91 } |
| 92 if (l1 > l0) { |
| 93 ogf_swap(l0 , l1 ); |
| 94 ogf_swap(i_[0], i_[1]); |
| 95 } |
| 96 } |
| 97 |
| 98 //_________________________________________________________ |
| 99 |
| 100 } // OGF namespace |
OLD | NEW |