26 #ifndef vsr_linkages_INC
27 #define vsr_linkages_INC
29 #include "vsr_chain.h"
31 namespace vsr{
namespace cga {
50 VSR_PRECISION mLengthA;
51 VSR_PRECISION mLengthB;
53 VSR_PRECISION mOffsetA;
54 VSR_PRECISION mOffsetB;
65 Bennett( VSR_PRECISION theta, VSR_PRECISION lengthA, VSR_PRECISION lengthB )
66 :
Chain(
"RRRR"), mTheta(theta), mLengthA( lengthA ), mLengthB( lengthB ), mPhase(0) {
70 Bennett( VSR_PRECISION theta, VSR_PRECISION lengthA, VSR_PRECISION lengthB, VSR_PRECISION offset )
71 :
Chain(
"RRRR"), mTheta(theta), mLengthA( lengthA ), mLengthB( lengthB ), mOffsetA(offset), mOffsetB(offset), mPhase(0) {
76 void set( VSR_PRECISION theta, VSR_PRECISION lengthA, VSR_PRECISION lengthB, VSR_PRECISION offset=0.0){
77 mTheta = theta; mLengthA = lengthA; mLengthB = lengthB; mOffsetA = offset; mOffsetB = offset;
83 mPhi = asin( sin(mTheta) * mLengthB / mLengthA);
85 mLink[0].pos(0,mLengthA, 0);
86 mLink[2].pos(0,mLengthA, 0);
88 mLink[1].pos(0,mLengthB, 0);
89 mLink[3].pos(0,mLengthB, 0);
91 Biv la = Biv::xz * mTheta/2.0;
92 Biv lb = Biv::xz * mPhi/2.0;
102 VSR_PRECISION lengthA()
const {
return mLengthA; }
103 VSR_PRECISION lengthB()
const {
return mLengthB; }
104 VSR_PRECISION& lengthA() {
return mLengthA; }
105 VSR_PRECISION& lengthB() {
return mLengthB; }
108 VSR_PRECISION offsetA()
const {
return mOffsetA; }
109 VSR_PRECISION offsetB()
const {
return mOffsetB; }
110 VSR_PRECISION& offsetA() {
return mOffsetA; }
111 VSR_PRECISION& offsetB() {
return mOffsetB; }
113 VSR_PRECISION theta()
const {
return mTheta; }
114 VSR_PRECISION phi()
const {
return mPhi; }
135 Bennett& operator()( VSR_PRECISION amt ){
138 bool bSwitch = sin(amt) < 0 ?
true :
false;
151 Pair p = (
mFrame[1].dxy() ^ dualMeet).dual();
157 for (
int i = 1; i < 4; ++i){
159 int next = i < 3 ? i + 1 : 0;
160 auto target =
mFrame[next].vec();
164 Vec dv = (target-
mFrame[i].vec()).unit().spin( linkRot );
167 mJoint[i].rot() =
Gen::rot( Biv::xy * acos( ( dv <= y )[0] )/2.0 * (bSwitch ? -1 : 1 ) );
185 Bennett linkRatio(VSR_PRECISION th, VSR_PRECISION a = .5, VSR_PRECISION b =.5, VSR_PRECISION la = 0, VSR_PRECISION lb = 0){
187 Bennett b2(mTheta * th, mLengthA * a, mLengthB * b);
192 if (la==0) la = mLengthA;
193 if (lb==0) lb = mLengthB;
195 Bennett b3(mTheta * th, la, lb);
215 Bennett linkAt(
int N=2, VSR_PRECISION th=1, VSR_PRECISION a = .5, VSR_PRECISION b =.5, VSR_PRECISION la = 0, VSR_PRECISION lb = 0){
218 bool bSwitch = sin(mPhase) < 0 ?
true :
false;
221 Bennett b2(mTheta * th, mLengthA * a, mLengthB * b);
228 if (la==0) la = mLengthA;
229 if (lb==0) lb = mLengthB;
232 Bennett b3(mTheta * th, la, lb);
234 for (
int i=0;i<b3.num();++i){
242 Bennett linkAt_(
int N, VSR_PRECISION th=1, VSR_PRECISION a = .5, VSR_PRECISION b =.5, VSR_PRECISION la = 0, VSR_PRECISION lb = 0){
244 bool bSwitch = sin(mPhase) < 0 ?
true :
false;
246 Bennett b2(mTheta * th, mLengthA * a, mLengthB * b);
263 Chain mChainA, mChainB;
265 VSR_PRECISION mRatio, mDecay;
269 Pantograph(
int n=1) : mChainA(n), mChainB(n), mRatio(1), mDecay(0)
273 void alloc(
int n) { mChainA.alloc(n); mChainB.alloc(n); }
274 void reset(){ mChainA.reset(); mChainB.reset(); }
275 void fk() { mChainA.
fk(); mChainB.
fk(); }
277 void ratio(VSR_PRECISION amt) { mRatio = amt; }
278 void decay(VSR_PRECISION amt) { mDecay = amt; }
280 VSR_PRECISION ratio()
const {
return mRatio; }
281 VSR_PRECISION decay()
const {
return mDecay; }
286 VSR_PRECISION tRatio = mRatio;
291 Dlp dlp = mChainA[0].
dxy().unit();
293 for (
int i = 0; i < mChainA.num(); i+=2 ){
298 Dls ta = flip ? da : da.dil( mChainA[i].pos(), log(tRatio) );
299 Dls tb = !flip ? db : db.dil( mChainB[i].pos(), log(tRatio) );
306 Par p = ( ta ^ tb ^ dlp ).dual();
309 mChainA[i+1].
pos() = pnt;
310 mChainB[i+1].
pos() = pnt;
312 double a = ( 1.0 / tRatio );
315 if (i < mChainA.num() - 2){
317 ( ( mChainA[i+1].vec() - mChainA[i].vec() ) * (1 + ( (flip) ? b : a ) ) ) );
319 ( ( mChainB[i+1].vec() - mChainB[i].vec() ) * (1 + ( (flip) ? a : b ) ) ) );
324 tRatio *= (1-mDecay);
333 Chain& chainA() {
return mChainA; }
334 Chain& chainB() {
return mChainB; }
static std::vector< Point > split(const Pair &pp)
Split Points from Point Pair.
Bennett linkAt(int N=2, VSR_PRECISION th=1, VSR_PRECISION a=.5, VSR_PRECISION b=.5, VSR_PRECISION la=0, VSR_PRECISION lb=0)
A linked Bennett mechanism at joint N determined by ratio of original We first create a sublinkage in...
Definition: vsr_linkages.h:215
void calcJoints(int start=0, bool bLoop=false)
Derive Joint Rotations from Current Positions.
Definition: vsr_chain.h:531
NVec< 5 > Vec
Vector
Definition: vsr_cga3D_types.h:62
Point pos() const
Get Position.
Definition: vsr_cga3D_frame.h:138
Multivector spin(const MultivectorB< B > &b) const
Rotor (even) transformation \(RA\tilde{R}\)
Definition: vsr_multivector.h:178
Mot mot() const
Get Absolute Motor Relative to Origin.
Par Pair
Point Pair 2-blade \(\tau=p_a \wedge p_b=\{e_{12},e_{13},e_{23},e_{1}n_o,e_{2}n_o,e_{3}n_o,e_{1}n_\infty,e_{2}n_\infty,e_{3}n_\infty,n_{o}n_\infty\}\)
Definition: vsr_cga3D_types.h:129
PANTOGRAPH for scissor-like kinematics.
Definition: vsr_linkages.h:261
Generic Geometric Number Types (templated on an algebra and a basis )
Definition: vsr_algebra.h:69
static Rot rot(const Biv &b)
vsr::cga::Rotor from vsr::cga::Bivector
The bennett 4 bar linkage.
Definition: vsr_linkages.h:48
Dlp dxy() const
xy dual plane
Frame & scale(VSR_PRECISION s)
Set Scale.
Definition: vsr_cga3D_frame.h:83
vector< Frame > mFrame
Absolute frames of Joints = prevFrame * prevLink * joint.
Definition: vsr_chain.h:118
Dlp nextPlane(int k) const
Dual Plane of rotation of kth joint (translated by link rejection from yz)
Definition: vsr_chain.h:261
Vec vec() const
Get Euclidean Vector of position.
Definition: vsr_cga3D_frame.h:142
static Point location(const A &s)
Location (normalized) of A Round Element (normalized) (Shorthand)
Definition: vsr_cga3D_round.h:136
Dls nextSphere(int k) const
Sphere Centered at Joint K Going Through Joint K+1.
Definition: vsr_chain.h:252
Cir Circle
Direct Circle 3-blade \(\kappa=p_a \wedge p_b \wedge p_c\)
Definition: vsr_cga3D_types.h:130
void fk()
Forward Kinematics: Absolute Concatenations of previous frame, previous link, and current joint...
Definition: vsr_chain.h:335
Frame()
Default Constructor.
Frame & mot(const Mot &m)
Set position and orientation by motor (absolute)
A sequence of spatial Frames.
Definition: vsr_chain.h:107
vector< Frame > mLink
Relative Link to NEXT joint.
Definition: vsr_chain.h:116
Dls prevSphere(int k) const
Sphere Centered at Joint K Going Through Joint K-1.
Definition: vsr_chain.h:256
static VSR_PRECISION iphi(const GARot< A > &r)
Angle of Rotation from Rotor.
Definition: vsr_generic_op.h:339
static Rot ratio(const Vec &v, const Vec &v2)
vsr::cga::Rotor that takes one vec to another
Circle circleMeet()
Meet of 1st and 3rd spheres of possibilities.
Definition: vsr_linkages.h:119
the versor library namespace
Definition: vsr_algebra.h:29
Rotor rot() const
Get 4x4 Rotation Matrix.
Definition: vsr_cga3D_frame.h:97
static VSR_PRECISION size(const DualSphere &s, bool bDual=true)
Squared Size of a DualSphere (result could be negative)
Frame & joint(int k)
set kth joint's In Socket Transformation
Definition: vsr_chain.h:236
Frame mBaseFrame
default zero, to tie chains together, set this to another chain's frame.
Definition: vsr_chain.h:111
vector< Frame > mJoint
In Socket Transformation (RDHC, etc) SET THIS directly using joint(i) (all others follow after callin...
Definition: vsr_chain.h:113
static Point null(const Vec &v)
Null Point from a vec.
Bennett linkRatio(VSR_PRECISION th, VSR_PRECISION a=.5, VSR_PRECISION b=.5, VSR_PRECISION la=0, VSR_PRECISION lb=0)
A linked Bennett mechanism, determined by ratio of original.
Definition: vsr_linkages.h:185
static GADls< A > dls_pnt(const GAPnt< A > &p, VSR_PRECISION r=1.0)
Dual Sphere from Point and Radius (faster)
Definition: vsr_generic_op.h:630
NRot< 5 > Rot
Rotor
Definition: vsr_cga3D_types.h:64