-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new trajectory and rework on existing trajectories
- Loading branch information
Showing
15 changed files
with
216 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include "visual/Circular.h" | ||
|
||
|
||
Circular::Circular(double s,double xOr, double yOr,double xc,double yc) | ||
: Trajectory(s,xOr,yOr) | ||
{ | ||
this->centerX = xc; | ||
this->centerY = yc; | ||
std::vector<double> orig=getOrigin(); | ||
this->radius=sqrt((orig[0]-centerX)*(orig[0]-centerX)+(orig[1]-centerY)*(orig[1]-centerY)); | ||
} | ||
|
||
Circular::Circular(double s,double xOr, double yOr,double r) | ||
: Trajectory(s,xOr,yOr) | ||
{ | ||
std::vector<double> orig=getOrigin(); | ||
this->centerX = orig[0]; | ||
this->centerY = orig[1]; | ||
this->radius=r; | ||
} | ||
|
||
|
||
|
||
|
||
std::vector<double> Circular::computeTrajectory(double dt) | ||
{ | ||
double sp = this->getSpeed(); | ||
double ph=this->getPhase(); | ||
const double PI =3.141592653589793238463; | ||
//define the phase modulo the period of the trajectory to avoid having phase going to infinity | ||
setPhase(fmod(getPhase()+dt,1./sp)); | ||
std::vector<double> orig=getOrigin(); | ||
std::vector<double> vecPos{0., 0.}; | ||
|
||
//we compute the euclidean distance between center of the circle and origin of trajectory | ||
vecPos[0] = radius*cos(sp*ph*2*PI)+orig[0]; | ||
vecPos[1] = radius*sin(sp*ph*2*PI)+orig[1]; | ||
return vecPos; | ||
} | ||
|
||
Circular::~Circular() | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef CIRCULAR_H | ||
#define CIRCULAR_H | ||
|
||
#include <vector> | ||
#include <memory> | ||
#include <iostream> | ||
#include "theglobals.h" | ||
#include "Trajectory.h" | ||
|
||
|
||
class Circular : public Trajectory { | ||
public: | ||
Circular(double s,double xOr, double yOr,double xc,double yc); | ||
Circular(double s,double xOr, double yOr,double r); | ||
double getCenter(); | ||
void setCenter(double x,double y); | ||
std::vector<double> computeTrajectory(double dt); | ||
~Circular(); | ||
|
||
private: | ||
double centerX; | ||
double centerY; | ||
double radius; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.