10 #ifndef VSR_TWIST_H_INCLUDED
11 #define VSR_TWIST_H_INCLUDED
15 #include "vsr_interp.h"
17 namespace vsr {
namespace cga {
42 mDll =
Dll(0,1,0,0,-1,0);
47 Twist(
const T& axis) : mExt(1) {
55 Twist(
double x,
double y,
double z): mExt(1) {
56 Biv b = Op::dl(
Vec(x,y,z));
81 double period()
const {
return biv().norm(); }
84 return Vec( drv().copy<Vec>() ).norm();
90 double moment()
const {
return iphi().rnorm(); }
100 Vec dir = Op::dle(tb);
102 dll(tb,
Drv( tv - (dir * pitch).copy<Drv>() ) );
114 Vec dir = Op::dle(tb);
115 Drv drv( tv + ( dir * pitch ).copy<Drv>() );
117 return Dll(tb[0], tb[1], tb[2], drv[0], drv[1], drv[2] );
121 Biv iphi()
const {
return Op::dle(biv()) ^
Vec(drv()); }
122 Biv pitchPlane()
const {
return iphi().unit(); }
124 void dll(
const Biv& b,
const Drv & d) {
125 mDll[0] = b[0]; mDll[1] = b[1]; mDll[2] = b[2];
126 mDll[3] = d[0]; mDll[4] = d[1]; mDll[5] = d[2];
129 Dll dll(
double t )
const {
return mDll * t; }
130 Dll dll()
const {
return mDll; }
131 Dll& dll() {
return mDll; }
134 Biv biv()
const {
return Biv(mDll); }
135 Drv drv()
const {
return Drv(mDll); }
137 void period(
double theta){
139 dll( mBiv * theta, drv() );
146 dll(biv(), mDrv * dt);
159 friend ostream& operator << (ostream&,
const Twist&);
163 inline ostream& operator << (ostream& os,
const Twist& t){
164 os << t.dll() <<
" pitch: " << t.pitch() <<
" period: " << t.period() <<
" moment: " << t.moment();
176 mTwist[0] =
Twist(1,0,0);
177 mTwist[1] =
Twist(0,1,0);
178 mTwist[2] =
Twist(0,0,1);
185 Twist& x() {
return mTwist[0]; }
186 Twist& y() {
return mTwist[1]; }
187 Twist& z() {
return mTwist[2]; }
189 Twist x()
const {
return mTwist[0]; }
190 Twist y()
const {
return mTwist[1]; }
191 Twist z()
const {
return mTwist[2]; }
194 void ext(
double _x,
double _y,
double _z){
202 void pitch(
double theta,
int i ){ mTwist[i].
pitch(theta); }
204 double period(
int i ) {
return mTwist[i].
period(); }
205 void period(
double theta,
int i ) { mTwist[i].
period(theta); }
207 void pitch(
double tx,
double ty,
double tz) {
pitchX(tx); pitchY(ty); pitchZ(tz); }
208 void period(
double tx,
double ty,
double tz) {
periodX(tx); periodY(ty); periodZ(tz); }
211 void pitchY(
double theta ) {
pitch(theta,1); }
212 void pitchZ(
double theta ) {
pitch(theta,2); }
213 void periodX(
double theta ) { period(theta,0); }
214 void periodY(
double theta ) { period(theta,1); }
215 void periodZ(
double theta ) { period(theta,2); }
218 Mot mot(
double t) {
return mTwist[2].mot(t) * mTwist[1].mot(t) * mTwist[0].mot(t); }
234 vector<Twist> mTwist;
242 NTwist(
int n) : mNum(n) { mTwist.resize(mNum); }
243 ~
NTwist() {
if (mDll)
delete[] mDll; }
251 Twist twist(
int idx)
const {
return mTwist[idx]; }
254 double pitch(
int i ) {
return mTwist[i].pitch(); }
255 void pitch(
double theta,
int i ){ mTwist[i].pitch(theta); }
257 double period(
int i ) {
return mTwist[i].period(); }
258 void period(
double theta,
int i ) { mTwist[i].period(theta); }
264 for (
int i =mNum-1; i >= 0; --i){
265 rm = rm * mTwist[i].mot(t);
272 for (
int i = 0; i < mNum; ++i){
273 tdll += mTwist[i].dll();
279 if (mDll)
delete[] mDll;
280 mDll =
new Dll[mNum];
281 for (
int i = 0; i < mNum; ++i){ mDll[i] = mTwist[i].dll(); }
286 return Interp::quadric<Dll>(mDll, mNum, t);
Twist & along(const Dll &d, double period, double pitch)
given a (unit?) line, generate a dll with period and pitch along it
Definition: vsr_twist.h:93
Dll & operator[](int idx)
Gets raw data (dual line) of twist.
Definition: vsr_twist.h:182
Common Operations Specific to CGA3D.
double moment() const
Distance from origin.
Definition: vsr_twist.h:90
NDrv< 5 > Drv
DirectionVector
Definition: vsr_cga3D_types.h:84
NVec< 5 > Vec
Vector
Definition: vsr_cga3D_types.h:62
Generic Geometric Number Types (templated on an algebra and a basis )
Definition: vsr_algebra.h:69
Dll & operator[](int idx)
Gets raw data (dual line) of twist.
Definition: vsr_twist.h:246
static Rot rot(const Biv &b)
vsr::cga::Rotor from vsr::cga::Bivector
static Mot mot(const Dll &dll)
Generate a vsr::cga::Motor from a vsr::cga::DualLine Axis.
Dll at(double t)
Interpolated Generators (t from 0 to 1)
Definition: vsr_twist.h:285
Dll dll(double t)
Bivector Generator of motor at t.
Definition: vsr_twist.h:220
void moveBy(const T &vec)
Direction.
Definition: vsr_twist.h:67
NDll< 5 > Dll
DualLine
Definition: vsr_cga3D_types.h:79
double period() const
Period, i.e frequency, of twist (in PI units)
Definition: vsr_twist.h:81
void pitch(double dt)
Pass in 0 to 1 -> if 1 pitch is 1.
Definition: vsr_twist.h:144
Coupled Twist Shape Generation x, y, z (after Rosenhahn et al)
Definition: vsr_twist.h:169
double pitch(int i)
Get Pitch.
Definition: vsr_twist.h:201
GENERIC n-TWIST mechanism.
Definition: vsr_twist.h:231
Mot mot(double t)
Concatenated Motors (x first, then y, then z ) with weight of t.
Definition: vsr_twist.h:261
double pitch(int i)
Get Pitch.
Definition: vsr_twist.h:254
static Rot ratio(const Vec &v, const Vec &v2)
vsr::cga::Rotor that takes one vec to another
Twist & twist(int idx)
Gets Twist at idx.
Definition: vsr_twist.h:250
the versor library namespace
Definition: vsr_algebra.h:29
B copy() const
Copying to type B.
void set(const Mot &m)
Set Twist Axis From Destination Motor.
Definition: vsr_twist.h:157
Mot mot(double t)
Concatenated Motors (x first, then y, then z ) with weight of t.
Definition: vsr_twist.h:218
Mot mot(double t) const
Get Motor at t.
Definition: vsr_twist.h:154
void periodX(double theta)
Set Period.
Definition: vsr_twist.h:213
double pitch() const
Pitch from 0 (othogonal, pure rotation) to 1 ( identical, pure translation )
Definition: vsr_twist.h:83
static Biv log(const Rot &r)
vsr::cga::Bivector log of vsr::cga::Rotor
NBiv< 5 > Biv
Bivector
Definition: vsr_cga3D_types.h:63
void ext(double _x, double _y, double _z)
set extrapolation per twist
Definition: vsr_twist.h:194
static Trs trs(const A &a)
vsr::cga::Translator from any type
Definition: vsr_cga3D_op.h:136
Dll dll()
Averaged Generators.
Definition: vsr_twist.h:224
void set(double distance, double period)
Set Distance and Period.
Definition: vsr_twist.h:74
Dll dll()
Averaged Generators.
Definition: vsr_twist.h:270
Decomposed Dual Line (As a Bivector and Direction Vector to it )
Definition: vsr_twist.h:20
void pitchX(double theta)
Set Pitch.
Definition: vsr_twist.h:210
NMot< 5 > Mot
Motor
Definition: vsr_cga3D_types.h:92