1c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// This file is part of Eigen, a lightweight C++ template library 2c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// for linear algebra. 3c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// 4c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// Copyright (C) 2010-2011 Hauke Heibel <heibel@gmail.com> 5c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// 6c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// This Source Code Form is subject to the terms of the Mozilla 7c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// Public License v. 2.0. If a copy of the MPL was not distributed 8c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 10c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath#include "main.h" 11c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 12c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath#include <unsupported/Eigen/Splines> 13c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 14c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// lets do some explicit instantiations and thus 15c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// force the compilation of all spline functions... 16c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate class Spline<double, 2, Dynamic>; 17c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate class Spline<double, 3, Dynamic>; 18c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 19c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate class Spline<double, 2, 2>; 20c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate class Spline<double, 2, 3>; 21c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate class Spline<double, 2, 4>; 22c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate class Spline<double, 2, 5>; 23c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 24c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate class Spline<float, 2, Dynamic>; 25c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate class Spline<float, 3, Dynamic>; 26c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 27c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate class Spline<float, 3, 2>; 28c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate class Spline<float, 3, 3>; 29c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate class Spline<float, 3, 4>; 30c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate class Spline<float, 3, 5>; 31c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 32c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathSpline<double, 2, Dynamic> closed_spline2d() 33c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{ 34c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath RowVectorXd knots(12); 35c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath knots << 0, 36c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0, 37c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0, 38c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0, 39c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.867193179093898, 40c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 1.660330955342408, 41c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 2.605084834823134, 42c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 3.484154586374428, 43c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 4.252699478956276, 44c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 4.252699478956276, 45c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 4.252699478956276, 46c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 4.252699478956276; 47c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 48c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath MatrixXd ctrls(8,2); 49c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath ctrls << -0.370967741935484, 0.236842105263158, 50c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath -0.231401860693277, 0.442245185027632, 51c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.344361228532831, 0.773369994120753, 52c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.828990216203802, 0.106550882647595, 53c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.407270163678382, -1.043452922172848, 54c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath -0.488467813584053, -0.390098582530090, 55c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath -0.494657189446427, 0.054804824897884, 56c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath -0.370967741935484, 0.236842105263158; 57c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath ctrls.transposeInPlace(); 58c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 59c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return Spline<double, 2, Dynamic>(knots, ctrls); 60c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath} 61c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 62c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/* create a reference spline */ 63c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathSpline<double, 3, Dynamic> spline3d() 64c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{ 65c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath RowVectorXd knots(11); 66c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath knots << 0, 67c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0, 68c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0, 69c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.118997681558377, 70c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.162611735194631, 71c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.498364051982143, 72c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.655098003973841, 73c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.679702676853675, 74c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 1.000000000000000, 75c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 1.000000000000000, 76c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 1.000000000000000; 77c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 78c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath MatrixXd ctrls(8,3); 79c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath ctrls << 0.959743958516081, 0.340385726666133, 0.585267750979777, 80c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.223811939491137, 0.751267059305653, 0.255095115459269, 81c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.505957051665142, 0.699076722656686, 0.890903252535799, 82c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.959291425205444, 0.547215529963803, 0.138624442828679, 83c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.149294005559057, 0.257508254123736, 0.840717255983663, 84c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.254282178971531, 0.814284826068816, 0.243524968724989, 85c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.929263623187228, 0.349983765984809, 0.196595250431208, 86c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.251083857976031, 0.616044676146639, 0.473288848902729; 87c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath ctrls.transposeInPlace(); 88c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 89c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return Spline<double, 3, Dynamic>(knots, ctrls); 90c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath} 91c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 92c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/* compares evaluations against known results */ 93c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathvoid eval_spline3d() 94c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{ 95c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath Spline3d spline = spline3d(); 96c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 97c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath RowVectorXd u(10); 98c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath u << 0.351659507062997, 99c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.830828627896291, 100c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.585264091152724, 101c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.549723608291140, 102c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.917193663829810, 103c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.285839018820374, 104c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.757200229110721, 105c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.753729094278495, 106c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.380445846975357, 107c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.567821640725221; 108c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 109c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath MatrixXd pts(10,3); 110c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath pts << 0.707620811535916, 0.510258911240815, 0.417485437023409, 111c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.603422256426978, 0.529498282727551, 0.270351549348981, 112c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.228364197569334, 0.423745615677815, 0.637687289287490, 113c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.275556796335168, 0.350856706427970, 0.684295784598905, 114c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.514519311047655, 0.525077224890754, 0.351628308305896, 115c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.724152914315666, 0.574461155457304, 0.469860285484058, 116c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.529365063753288, 0.613328702656816, 0.237837040141739, 117c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.522469395136878, 0.619099658652895, 0.237139665242069, 118c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.677357023849552, 0.480655768435853, 0.422227610314397, 119c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.247046593173758, 0.380604672404750, 0.670065791405019; 120c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath pts.transposeInPlace(); 121c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 122c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath for (int i=0; i<u.size(); ++i) 123c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 124c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath Vector3d pt = spline(u(i)); 125c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath VERIFY( (pt - pts.col(i)).norm() < 1e-14 ); 126c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 127c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath} 128c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 129c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/* compares evaluations on corner cases */ 130c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathvoid eval_spline3d_onbrks() 131c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{ 132c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath Spline3d spline = spline3d(); 133c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 134c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath RowVectorXd u = spline.knots(); 135c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 136c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath MatrixXd pts(11,3); 137c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath pts << 0.959743958516081, 0.340385726666133, 0.585267750979777, 138c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.959743958516081, 0.340385726666133, 0.585267750979777, 139c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.959743958516081, 0.340385726666133, 0.585267750979777, 140c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.430282980289940, 0.713074680056118, 0.720373307943349, 141c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.558074875553060, 0.681617921034459, 0.804417124839942, 142c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.407076008291750, 0.349707710518163, 0.617275937419545, 143c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.240037008286602, 0.738739390398014, 0.324554153129411, 144c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.302434111480572, 0.781162443963899, 0.240177089094644, 145c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.251083857976031, 0.616044676146639, 0.473288848902729, 146c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.251083857976031, 0.616044676146639, 0.473288848902729, 147c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.251083857976031, 0.616044676146639, 0.473288848902729; 148c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath pts.transposeInPlace(); 149c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 150c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath for (int i=0; i<u.size(); ++i) 151c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 152c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath Vector3d pt = spline(u(i)); 153c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath VERIFY( (pt - pts.col(i)).norm() < 1e-14 ); 154c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 155c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath} 156c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 157c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathvoid eval_closed_spline2d() 158c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{ 159c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath Spline2d spline = closed_spline2d(); 160c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 161c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath RowVectorXd u(12); 162c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath u << 0, 163c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.332457030395796, 164c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.356467130532952, 165c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.453562180176215, 166c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.648017921874804, 167c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.973770235555003, 168c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 1.882577647219307, 169c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 2.289408593930498, 170c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 3.511951429883045, 171c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 3.884149321369450, 172c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 4.236261590369414, 173c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 4.252699478956276; 174c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 175c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath MatrixXd pts(12,2); 176c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath pts << -0.370967741935484, 0.236842105263158, 177c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath -0.152576775123250, 0.448975001279334, 178c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath -0.133417538277668, 0.461615613865667, 179c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath -0.053199060826740, 0.507630360006299, 180c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.114249591147281, 0.570414135097409, 181c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.377810316891987, 0.560497102875315, 182c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.665052120135908, -0.157557441109611, 183c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 0.516006487053228, -0.559763292174825, 184c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath -0.379486035348887, -0.331959640488223, 185c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath -0.462034726249078, -0.039105670080824, 186c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath -0.378730600917982, 0.225127015099919, 187c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath -0.370967741935484, 0.236842105263158; 188c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath pts.transposeInPlace(); 189c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 190c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath for (int i=0; i<u.size(); ++i) 191c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 192c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath Vector2d pt = spline(u(i)); 193c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath VERIFY( (pt - pts.col(i)).norm() < 1e-14 ); 194c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 195c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath} 196c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 197c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathvoid check_global_interpolation2d() 198c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{ 199c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath typedef Spline2d::PointType PointType; 200c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath typedef Spline2d::KnotVectorType KnotVectorType; 201c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath typedef Spline2d::ControlPointVectorType ControlPointVectorType; 202c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 203c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath ControlPointVectorType points = ControlPointVectorType::Random(2,100); 204c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 205c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath KnotVectorType chord_lengths; // knot parameters 206c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath Eigen::ChordLengths(points, chord_lengths); 207c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 208c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath // interpolation without knot parameters 209c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 210c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath const Spline2d spline = SplineFitting<Spline2d>::Interpolate(points,3); 211c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 212c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath for (Eigen::DenseIndex i=0; i<points.cols(); ++i) 213c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 214c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath PointType pt = spline( chord_lengths(i) ); 215c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath PointType ref = points.col(i); 216c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath VERIFY( (pt - ref).matrix().norm() < 1e-14 ); 217c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 218c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 219c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 220c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath // interpolation with given knot parameters 221c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 222c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath const Spline2d spline = SplineFitting<Spline2d>::Interpolate(points,3,chord_lengths); 223c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 224c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath for (Eigen::DenseIndex i=0; i<points.cols(); ++i) 225c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 226c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath PointType pt = spline( chord_lengths(i) ); 227c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath PointType ref = points.col(i); 228c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath VERIFY( (pt - ref).matrix().norm() < 1e-14 ); 229c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 230c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 231c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath} 232c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 233c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 234c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathvoid test_splines() 235c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{ 236c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath CALL_SUBTEST( eval_spline3d() ); 237c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath CALL_SUBTEST( eval_spline3d_onbrks() ); 238c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath CALL_SUBTEST( eval_closed_spline2d() ); 239c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath CALL_SUBTEST( check_global_interpolation2d() ); 240c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath} 241