height_map.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 Copyright (c) 2018, Alexander W. Winkler. All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without
00005 modification, are permitted provided that the following conditions are met:
00006 
00007 * Redistributions of source code must retain the above copyright notice, this
00008   list of conditions and the following disclaimer.
00009 
00010 * Redistributions in binary form must reproduce the above copyright notice,
00011   this list of conditions and the following disclaimer in the documentation
00012   and/or other materials provided with the distribution.
00013 
00014 * Neither the name of the copyright holder nor the names of its
00015   contributors may be used to endorse or promote products derived from
00016   this software without specific prior written permission.
00017 
00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00021 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00022 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00023 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00024 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00025 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00026 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00027 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00028 ******************************************************************************/
00029 
00030 #ifndef TOWR_HEIGHT_MAP_H_
00031 #define TOWR_HEIGHT_MAP_H_
00032 
00033 #include <memory>
00034 #include <vector>
00035 #include <Eigen/Dense>
00036 
00037 #include "variables/cartesian_dimensions.h"
00038 
00039 namespace towr {
00040 
00053 class HeightMap {
00054 public:
00055   using Ptr      = std::shared_ptr<HeightMap>;
00056   using Vector3d = Eigen::Vector3d;
00057 
00058   enum Direction { Normal, Tangent1, Tangent2 };
00059 
00060   HeightMap() = default;
00061   virtual ~HeightMap () = default;
00062 
00068   virtual double GetHeight(double x, double y) const = 0;
00069 
00077   double GetDerivativeOfHeightWrt(Dim2D dim, double x, double y) const;
00078 
00086   Vector3d GetNormalizedBasis(Direction direction, double x, double y) const;
00087 
00096   Vector3d GetDerivativeOfNormalizedBasisWrt(Direction direction, Dim2D dim,
00097                                              double x, double y) const;
00101   double GetFrictionCoeff() const { return friction_coeff_; };
00102 
00103 protected:
00104   double friction_coeff_ = 0.5;
00105 
00106 private:
00107   using DimDerivs = std::vector<Dim2D>; 
00108 
00117   Vector3d GetBasis(Direction direction, double x, double y,
00118                     const DimDerivs& dim_deriv= {}) const;
00119 
00120   Vector3d GetNormal(double x,   double y, const DimDerivs& = {}) const;
00121   Vector3d GetTangent1(double x, double y, const DimDerivs& = {}) const;
00122   Vector3d GetTangent2(double x, double y, const DimDerivs& = {}) const;
00123 
00124   double GetSecondDerivativeOfHeightWrt(Dim2D dim1, Dim2D dim2,
00125                                         double x, double y) const;
00126 
00127   Vector3d GetDerivativeOfNormalizedVectorWrtNonNormalizedIndex(
00128       const Vector3d& non_normalized, int index) const;
00129 
00130   // first derivatives that must be implemented by the user
00131   virtual double GetHeightDerivWrtX(double x, double y) const { return 0.0; };
00132   virtual double GetHeightDerivWrtY(double x, double y) const { return 0.0; };
00133 
00134   // second derivatives with respect to first letter, then second
00135   virtual double GetHeightDerivWrtXX(double x, double y) const { return 0.0; };
00136   virtual double GetHeightDerivWrtXY(double x, double y) const { return 0.0; };
00137   virtual double GetHeightDerivWrtYX(double x, double y) const { return 0.0; };
00138   virtual double GetHeightDerivWrtYY(double x, double y) const { return 0.0; };
00139 };
00140 
00141 } /* namespace towr */
00142 
00143 #endif /* TOWR_HEIGHT_MAP_H_ */


towr_core
Author(s): Alexander W. Winkler
autogenerated on Mon Apr 9 2018 03:12:44