Line.hpp
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2010, LABUST, UNIZG-FER
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of the LABUST nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *
00034  *  Created on: 26.06.2013.
00035  *  Author: Dula Nad
00036  *********************************************************************/
00037 #ifndef LINE_HPP_
00038 #define LINE_HPP_
00039 #include <Eigen/Dense>
00040 
00041 namespace labust
00042 {
00043         namespace math
00044         {
00048                 class Line
00049                 {
00050                         enum {xp,yp,zp};
00051                 public:
00055                         Line():
00056                                 Gamma(0),
00057                                 Xi(0),
00058                                 T1(Eigen::Vector3d::Zero()),
00059                                 T2(Eigen::Vector3d::Ones()){};
00063                         double calculatedH(double x0, double y0, double z0) const
00064                         {
00065                           double Lp = sqrt((T2(xp)-T1(xp))*(T2(xp)-T1(xp))+(T2(yp)-T1(yp))*(T2(yp)-T1(yp)));
00066                           //Note the minus thingy
00067                           return ((T2(xp)-T1(xp))*(T1(yp)-y0)-(T1(xp)-x0)*(T2(yp)-T1(yp)))/Lp;
00068                         }
00072                         double calculatedV(double x0, double y0, double z0) const
00073                         {
00074                           double Lp = sqrt(std::pow(T2(xp)-T1(xp),2) + std::pow(T2(yp)-T1(yp),2));
00075                           double L = sqrt(Lp*Lp + std::pow(T2(zp) - T1(zp),2));
00076                           double n = (T2(xp)-T1(xp))*(x0-T1(xp))+(T2(yp)-T1(yp))*(y0-T1(yp));
00077                           n *= -(T2(zp)-T1(zp));
00078                           n -= (T1(zp)-z0)*Lp*Lp;
00079 
00080                           return n/(Lp*L);
00081                         }
00088                         void setLine(const Eigen::Vector3d& T1, const Eigen::Vector3d& T2)
00089                         {
00090                           this->T1 = T1;
00091                           this->T2 = T2;
00092                           //select default north line.
00093                           if ((T1(0) == T2(0)) && (T1(1) == T2(1))) this->T2(0) = -1;
00094 
00095                           this->Gamma = atan2(T2(yp) - T1(yp),T2(xp) - T1(xp));
00096                           this->Xi = atan2(T2(zp) - T1(zp),
00097                                         sqrt(std::pow(T2(xp)-T1(xp),2) + std::pow(T2(yp)-T1(yp),2)));
00098                         }
00102                         inline const Eigen::Vector3d& getT1()
00103                         {
00104                                 return T1;
00105                         }
00109                         inline const Eigen::Vector3d& getT2()
00110                         {
00111                                 return T2;
00112                         }
00116                         inline double xi(){return this->Xi;};
00120                         inline double gamma(){return this->Gamma;};
00121 
00122                 protected:
00126                         double Gamma, Xi;
00130                         Eigen::Vector3d T1,T2;
00131                 };
00132         }
00133 }
00134 
00135 /* LINE_HPP_ */
00136 #endif


snippets
Author(s): Gyula Nagy
autogenerated on Mon Oct 6 2014 01:39:41