From 6655926e01396139f4b81323d8adcc734bc4284e Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sun, 1 Nov 2015 23:33:50 +0800 Subject: Add smPath source files. Sync with the latest BLR3. --- extensions/smpath.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 extensions/smpath.cpp (limited to 'extensions') diff --git a/extensions/smpath.cpp b/extensions/smpath.cpp new file mode 100644 index 0000000..9d73b4a --- /dev/null +++ b/extensions/smpath.cpp @@ -0,0 +1,27 @@ +#include +#include "smpath.hpp" +smPathSegment::smPathSegment(smvec2d _a,smvec2d _b){a=_a,b=_b;} +smvec2d smPathSegment::getPointOnPath(double rt) +{return a+rt*(b-a);} +double smPathSegment::getPathLength() +{return (a-b).l();} +smPathCircular::smPathCircular(smvec2d _ctr,double _a,double _b,double _r) +{ctr=_ctr,a=_a,b=_b,r=_r;} +smvec2d smPathCircular::getPointOnPath(double rt) +{return smvec2d(ctr.x+r*cos(a+rt*(b-a)),ctr.y+r*sin(a+rt*(b-a)));} +double smPathCircular::getPathLength() +{return fabs(a-b)*r;} +int smPathCollection::pushPath(smPathBase *p){paths[cpaths++]=p;return cpaths-1;} +smPathBase* smPathCollection::getPath(int pid){return paths[pid];} +smvec2d smPathCollection::getPointOnCollection(double rt) +{ + double l=0.,tl=0.; + int i; + for(i=0;igetPathLength(); + for(i=0;igetPathLength()>=l*rt)break; + tl+=paths[i]->getPathLength(); + } + return paths[i]->getPointOnPath(rt-tl/l); +} -- cgit v1.2.3