00001 /* 00002 * Copyright (C) 2007 Patrick Beeson 00003 * Copyright (C) 2010 Jack O'Quin 00004 * 00005 * License: Modified BSD Software License Agreement 00006 * 00007 * $Id: SmoothCurve.h 415 2010-08-19 00:23:10Z jack.oquin $ 00008 */ 00009 00016 #ifndef __SMOOTHCURVE_H__ 00017 #define __SMOOTHCURVE_H__ 00018 00019 #include <vector> 00020 00021 #include <art_map/vec.h> // TODO: eliminate this 00022 #include <art/epsilon.h> 00023 00024 typedef Vec2f Point2f; 00025 00026 class SmoothCurve 00027 { 00028 00029 public: 00030 SmoothCurve(){} 00031 00032 SmoothCurve(const std::vector<Point2f>& ctrl, 00033 float starttheta, float startspeed, 00034 float endtheta, float endspeed, bool use_pats=true); 00035 ~SmoothCurve(); 00036 00037 void clear(); 00038 00039 float curveLength(); 00040 00041 Point2f evaluatePoint(float time); 00042 00043 int knotCount() const; 00044 00045 std::vector<float> knots; 00046 00047 private: 00048 00049 int controlPointsCount() const; 00050 00051 int dataPointsCount() const; 00052 00053 std::vector<Point2f> dataPoints; 00054 std::vector<Point2f> controlPoints; 00055 00056 int degree; 00057 00058 float DeltaU (int i); 00059 00060 Point2f bezierPoint(int i); 00061 00062 Point2f Delta(int i); 00063 00064 00065 Point2f getDataPoint(int index) const; 00066 00067 Point2f getControlPoint(int index) const; 00068 00069 float getKnot(int index) const; 00070 00071 00072 }; 00073 00074 00075 #endif