Initial commit.
This commit is contained in:
commit
44b5f2392f
98 changed files with 11750 additions and 0 deletions
70
physics/translation.h
Normal file
70
physics/translation.h
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
// -*- C++ -*-
|
||||
|
||||
#ifndef MBOSTOCK_TRANSLATION_H
|
||||
#define MBOSTOCK_TRANSLATION_H
|
||||
|
||||
#include "shape.h"
|
||||
#include "transform.h"
|
||||
#include "vector.h"
|
||||
|
||||
namespace mbostock {
|
||||
|
||||
class Translation : public Transform {
|
||||
public:
|
||||
Translation(const Vector& x0, const Vector& x1,
|
||||
float s, float u, float kd);
|
||||
|
||||
enum Mode { REVERSE, RESET, ONE_WAY };
|
||||
|
||||
/* Sets the translation mode. The default is REVERSE. */
|
||||
void setMode(Mode m);
|
||||
|
||||
/** Translates the specified point. */
|
||||
Vector point(const Vector& x) const;
|
||||
|
||||
/** Inverse-translates the specified point. */
|
||||
Vector pointInverse(const Vector& x) const;
|
||||
|
||||
/** Advances the translation by one time step. */
|
||||
virtual void step();
|
||||
|
||||
/** Resets the translation. */
|
||||
virtual void reset();
|
||||
|
||||
/** Returns the current velocity. */
|
||||
const Vector& velocity() const;
|
||||
|
||||
/** Returns the current origin. */
|
||||
inline const Vector& origin() const { return origin_; }
|
||||
|
||||
private:
|
||||
void update();
|
||||
|
||||
Vector x0_;
|
||||
Vector x1_;
|
||||
float s_;
|
||||
float u_;
|
||||
float kd_;
|
||||
Vector v_;
|
||||
Vector dv_;
|
||||
Vector x_;
|
||||
Vector origin_;
|
||||
Mode mode_;
|
||||
bool reversed_;
|
||||
};
|
||||
|
||||
class TranslatingShape : public Shape {
|
||||
public:
|
||||
TranslatingShape(const Shape& s, const Translation& t);
|
||||
|
||||
virtual bool intersects(const Sphere& s) const;
|
||||
virtual Projection project(const Vector& x) const;
|
||||
|
||||
private:
|
||||
const Shape& shape_;
|
||||
const Translation& translation_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue