Skip to content

Commit

Permalink
Renamed code macros and templates for spline muscles
Browse files Browse the repository at this point in the history
  • Loading branch information
melund committed Sep 24, 2024
1 parent 721c825 commit 3649fbb
Show file tree
Hide file tree
Showing 3 changed files with 221 additions and 221 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#define UPPER(N) gteqfun(repmat(1,N, iarr(1, N))', repmat(1,N, iarr(1, N)))
#define LENGTH(P) sum(vnorm((arrcat(zeros(1,SizesOf(P)[0]-1), eye(SizesOf(P)[0]-1)')' - arrcat(eye(SizesOf(P)[0]-1)', zeros(1,SizesOf(P)[0]-1))')*P))
#define SPLINE_MUSLE_UPPER(N) gteqfun(repmat(1,N, iarr(1, N))', repmat(1,N, iarr(1, N)))
#define SPLINE_MUSLE_LENGTH(P) sum(vnorm((arrcat(zeros(1,SizesOf(P)[0]-1), eye(SizesOf(P)[0]-1)')' - arrcat(eye(SizesOf(P)[0]-1)', zeros(1,SizesOf(P)[0]-1))')*P))


#class_template CreateMuscleElement (__CLASS__=AnyMuscleViaPoint, NAME1,NAME2){
#class_template SplineMuscle_CreateElement (__CLASS__=AnyMuscleViaPoint, NAME1,NAME2){
AnyRefNode &Org = .OriginSegment.NAME1##_Org.NAME2;
AnyRefNode &Ins = .InsertionSegment.NAME1##_Ins.NAME2;
AnyMuscleModel MusMdl = {F0=..MuscleModel.F0/..NumberOfElements;Lf0=..MuscleModel.F0; Vol0=..MuscleModel.Vol0/..NumberOfElements;};
Expand Down Expand Up @@ -48,7 +48,7 @@



#class_template Muscle_template_Simple(
#class_template SplineMuscle_CreateMuscle(
CREATE_ELEMENTS,
AnyFolder &OriginSegment,
ORIGIN_POINTS,
Expand Down Expand Up @@ -103,121 +103,121 @@
};

#if CREATE_ELEMENTS >= 1
CreateMuscleElement elem1 (NAME1=__NAME__,NAME2=Node0)= {};
SplineMuscle_CreateElement elem1 (NAME1=__NAME__,NAME2=Node0)= {};
#endif
#if CREATE_ELEMENTS >= 2
CreateMuscleElement elem2 (NAME1=__NAME__,NAME2=Node1)= {};
SplineMuscle_CreateElement elem2 (NAME1=__NAME__,NAME2=Node1)= {};
#endif
#if CREATE_ELEMENTS >= 3
CreateMuscleElement elem3 (NAME1=__NAME__,NAME2=Node2)= {};
SplineMuscle_CreateElement elem3 (NAME1=__NAME__,NAME2=Node2)= {};
#endif
#if CREATE_ELEMENTS >= 4
CreateMuscleElement elem4 (NAME1=__NAME__,NAME2=Node3)= {};
SplineMuscle_CreateElement elem4 (NAME1=__NAME__,NAME2=Node3)= {};
#endif
#if CREATE_ELEMENTS >= 5
CreateMuscleElement elem5 (NAME1=__NAME__,NAME2=Node4)= {};
SplineMuscle_CreateElement elem5 (NAME1=__NAME__,NAME2=Node4)= {};
#endif
#if CREATE_ELEMENTS >= 6
CreateMuscleElement elem6 (NAME1=__NAME__,NAME2=Node5)= {};
SplineMuscle_CreateElement elem6 (NAME1=__NAME__,NAME2=Node5)= {};
#endif
#if CREATE_ELEMENTS >= 7
CreateMuscleElement elem7 (NAME1=__NAME__,NAME2=Node6)= {};
SplineMuscle_CreateElement elem7 (NAME1=__NAME__,NAME2=Node6)= {};
#endif
#if CREATE_ELEMENTS >= 8
CreateMuscleElement elem8 (NAME1=__NAME__,NAME2=Node7)= {};
SplineMuscle_CreateElement elem8 (NAME1=__NAME__,NAME2=Node7)= {};
#endif
#if CREATE_ELEMENTS >= 9
CreateMuscleElement elem9 (NAME1=__NAME__,NAME2=Node8)= {};
SplineMuscle_CreateElement elem9 (NAME1=__NAME__,NAME2=Node8)= {};
#endif
#if CREATE_ELEMENTS >= 10
CreateMuscleElement elem10 (NAME1=__NAME__,NAME2=Node9)= {};
SplineMuscle_CreateElement elem10 (NAME1=__NAME__,NAME2=Node9)= {};
#endif
#if CREATE_ELEMENTS >= 11
CreateMuscleElement elem11 (NAME1=__NAME__,NAME2=Node10)= {};
SplineMuscle_CreateElement elem11 (NAME1=__NAME__,NAME2=Node10)= {};
#endif
#if CREATE_ELEMENTS >= 12
CreateMuscleElement elem12 (NAME1=__NAME__,NAME2=Node11)= {};
SplineMuscle_CreateElement elem12 (NAME1=__NAME__,NAME2=Node11)= {};
#endif
#if CREATE_ELEMENTS >= 13
CreateMuscleElement elem13 (NAME1=__NAME__,NAME2=Node12)= {};
SplineMuscle_CreateElement elem13 (NAME1=__NAME__,NAME2=Node12)= {};
#endif
#if CREATE_ELEMENTS >= 14
CreateMuscleElement elem14 (NAME1=__NAME__,NAME2=Node13)= {};
SplineMuscle_CreateElement elem14 (NAME1=__NAME__,NAME2=Node13)= {};
#endif
#if CREATE_ELEMENTS >= 15
CreateMuscleElement elem15 (NAME1=__NAME__,NAME2=Node14)= {};
SplineMuscle_CreateElement elem15 (NAME1=__NAME__,NAME2=Node14)= {};
#endif
#if CREATE_ELEMENTS >= 16
CreateMuscleElement elem16 (NAME1=__NAME__,NAME2=Node15)= {};
SplineMuscle_CreateElement elem16 (NAME1=__NAME__,NAME2=Node15)= {};
#endif
#if CREATE_ELEMENTS >= 17
CreateMuscleElement elem17 (NAME1=__NAME__,NAME2=Node16)= {};
SplineMuscle_CreateElement elem17 (NAME1=__NAME__,NAME2=Node16)= {};
#endif
#if CREATE_ELEMENTS >= 18
CreateMuscleElement elem18 (NAME1=__NAME__,NAME2=Node17)= {};
SplineMuscle_CreateElement elem18 (NAME1=__NAME__,NAME2=Node17)= {};
#endif
#if CREATE_ELEMENTS >= 19
CreateMuscleElement elem19 (NAME1=__NAME__,NAME2=Node18)= {};
SplineMuscle_CreateElement elem19 (NAME1=__NAME__,NAME2=Node18)= {};
#endif
#if CREATE_ELEMENTS >= 20
CreateMuscleElement elem20 (NAME1=__NAME__,NAME2=Node19)= {};
SplineMuscle_CreateElement elem20 (NAME1=__NAME__,NAME2=Node19)= {};
#endif
#if CREATE_ELEMENTS >= 21
CreateMuscleElement elem21 (NAME1=__NAME__,NAME2=Node20)= {};
SplineMuscle_CreateElement elem21 (NAME1=__NAME__,NAME2=Node20)= {};
#endif
#if CREATE_ELEMENTS >= 22
CreateMuscleElement elem22 (NAME1=__NAME__,NAME2=Node21)= {};
SplineMuscle_CreateElement elem22 (NAME1=__NAME__,NAME2=Node21)= {};
#endif
#if CREATE_ELEMENTS >= 23
CreateMuscleElement elem23 (NAME1=__NAME__,NAME2=Node22)= {};
SplineMuscle_CreateElement elem23 (NAME1=__NAME__,NAME2=Node22)= {};
#endif
#if CREATE_ELEMENTS >= 24
CreateMuscleElement elem24 (NAME1=__NAME__,NAME2=Node23)= {};
SplineMuscle_CreateElement elem24 (NAME1=__NAME__,NAME2=Node23)= {};
#endif
#if CREATE_ELEMENTS >= 25
CreateMuscleElement elem25 (NAME1=__NAME__,NAME2=Node24)= {};
SplineMuscle_CreateElement elem25 (NAME1=__NAME__,NAME2=Node24)= {};
#endif
#if CREATE_ELEMENTS >= 26
CreateMuscleElement elem26 (NAME1=__NAME__,NAME2=Node25)= {};
SplineMuscle_CreateElement elem26 (NAME1=__NAME__,NAME2=Node25)= {};
#endif
#if CREATE_ELEMENTS >= 27
CreateMuscleElement elem27 (NAME1=__NAME__,NAME2=Node26)= {};
SplineMuscle_CreateElement elem27 (NAME1=__NAME__,NAME2=Node26)= {};
#endif
#if CREATE_ELEMENTS >= 28
CreateMuscleElement elem28 (NAME1=__NAME__,NAME2=Node27)= {};
SplineMuscle_CreateElement elem28 (NAME1=__NAME__,NAME2=Node27)= {};
#endif
#if CREATE_ELEMENTS >= 29
CreateMuscleElement elem29 (NAME1=__NAME__,NAME2=Node28)= {};
SplineMuscle_CreateElement elem29 (NAME1=__NAME__,NAME2=Node28)= {};
#endif
#if CREATE_ELEMENTS >= 30
CreateMuscleElement elem30 (NAME1=__NAME__,NAME2=Node29)= {};
SplineMuscle_CreateElement elem30 (NAME1=__NAME__,NAME2=Node29)= {};
#endif
#if CREATE_ELEMENTS >= 31
CreateMuscleElement elem31 (NAME1=__NAME__,NAME2=Node30)= {};
SplineMuscle_CreateElement elem31 (NAME1=__NAME__,NAME2=Node30)= {};
#endif
#if CREATE_ELEMENTS >= 32
CreateMuscleElement elem32 (NAME1=__NAME__,NAME2=Node31)= {};
SplineMuscle_CreateElement elem32 (NAME1=__NAME__,NAME2=Node31)= {};
#endif
#if CREATE_ELEMENTS >= 33
CreateMuscleElement elem33 (NAME1=__NAME__,NAME2=Node32)= {};
SplineMuscle_CreateElement elem33 (NAME1=__NAME__,NAME2=Node32)= {};
#endif
#if CREATE_ELEMENTS >= 34
CreateMuscleElement elem34 (NAME1=__NAME__,NAME2=Node33)= {};
SplineMuscle_CreateElement elem34 (NAME1=__NAME__,NAME2=Node33)= {};
#endif
#if CREATE_ELEMENTS >= 35
CreateMuscleElement elem35 (NAME1=__NAME__,NAME2=Node34)= {};
SplineMuscle_CreateElement elem35 (NAME1=__NAME__,NAME2=Node34)= {};
#endif
#if CREATE_ELEMENTS >= 36
CreateMuscleElement elem36 (NAME1=__NAME__,NAME2=Node35)= {};
SplineMuscle_CreateElement elem36 (NAME1=__NAME__,NAME2=Node35)= {};
#endif
#if CREATE_ELEMENTS >= 37
CreateMuscleElement elem37 (NAME1=__NAME__,NAME2=Node36)= {};
SplineMuscle_CreateElement elem37 (NAME1=__NAME__,NAME2=Node36)= {};
#endif
#if CREATE_ELEMENTS >= 38
CreateMuscleElement elem38 (NAME1=__NAME__,NAME2=Node37)= {};
SplineMuscle_CreateElement elem38 (NAME1=__NAME__,NAME2=Node37)= {};
#endif
#if CREATE_ELEMENTS >= 39
CreateMuscleElement elem39 (NAME1=__NAME__,NAME2=Node38)= {};
SplineMuscle_CreateElement elem39 (NAME1=__NAME__,NAME2=Node38)= {};
#endif


Expand All @@ -232,7 +232,7 @@
//C is a point on the insertion spline.
//the input to the calculation is a desired angle, a set of parameters values and two spline functions
//the spline functions
#define OFFSET(DesiredAngle, par,InsertionFun,OriginFun) \
#define SPLINE_MUSLE_OFFSET(DesiredAngle, par,InsertionFun,OriginFun) \
AnyFolder Offsets = { \
//small pertubation
AnyVar Pert = 0.001;\
Expand Down Expand Up @@ -275,7 +275,7 @@



#class_template Muscle_template_Simple_Angle_MultiOffset(
#class_template SplineMuscle_CreateMuscleMultiOffset(
CREATE_ELEMENTS,
AnyFolder &OriginSegment,
ORIGIN_POINTS,
Expand Down Expand Up @@ -316,10 +316,10 @@

AnyInt Origin_Size = SizesOf(ORIGIN_POINTS)[0];
AnyInt Insertion_Size = SizesOf(INSERTION_POINTS)[0];
AnyFloat Origin_Accum_L = arrcat(0.0,vnorm((DIFFMAT(Origin_Size))*ORIGIN_POINTS)*(UPPER(Origin_Size-1)));
AnyFloat Insertion_Accum_L = arrcat(0.0,vnorm((DIFFMAT(Insertion_Size))*INSERTION_POINTS)*(UPPER(Insertion_Size-1)));
AnyFloat Origin_L = LENGTH(ORIGIN_POINTS);
AnyFloat Insertion_L = LENGTH(INSERTION_POINTS);
AnyFloat Origin_Accum_L = arrcat(0.0,vnorm((DIFFMAT(Origin_Size))*ORIGIN_POINTS)*(SPLINE_MUSLE_UPPER(Origin_Size-1)));
AnyFloat Insertion_Accum_L = arrcat(0.0,vnorm((DIFFMAT(Insertion_Size))*INSERTION_POINTS)*(SPLINE_MUSLE_UPPER(Insertion_Size-1)));
AnyFloat Origin_L = SPLINE_MUSLE_LENGTH(ORIGIN_POINTS);
AnyFloat Insertion_L = SPLINE_MUSLE_LENGTH(INSERTION_POINTS);
AnyFloat Origin_REL_L = Origin_Accum_L/Origin_L;
AnyFloat Insertion_REL_L = Insertion_Accum_L/Insertion_L;

Expand Down Expand Up @@ -377,7 +377,7 @@ AnyFunInterpol Fun_Insertion_Extend = {
};

//calculate offsets
OFFSET(.DesiredAngle,.Origin_REL_L,Fun_Insertion_Extend,Fun_Origin_Extend)
SPLINE_MUSLE_OFFSET(.DesiredAngle,.Origin_REL_L,Fun_Insertion_Extend,Fun_Origin_Extend)

//Make interpolated offset function
AnyFunInterpol InsertionFun_Offset = {
Expand Down Expand Up @@ -425,121 +425,121 @@ AnyVector a_org = linspace(iffun(ltfun(min_,0),-min_+0.01,0.0),iffun(gtfun(max_,


#if CREATE_ELEMENTS >= 1
CreateMuscleElement elem1 (NAME1=__NAME__,NAME2=Node0)= {};
SplineMuscle_CreateElement elem1 (NAME1=__NAME__,NAME2=Node0)= {};
#endif
#if CREATE_ELEMENTS >= 2
CreateMuscleElement elem2 (NAME1=__NAME__,NAME2=Node1)= {};
SplineMuscle_CreateElement elem2 (NAME1=__NAME__,NAME2=Node1)= {};
#endif
#if CREATE_ELEMENTS >= 3
CreateMuscleElement elem3 (NAME1=__NAME__,NAME2=Node2)= {};
SplineMuscle_CreateElement elem3 (NAME1=__NAME__,NAME2=Node2)= {};
#endif
#if CREATE_ELEMENTS >= 4
CreateMuscleElement elem4 (NAME1=__NAME__,NAME2=Node3)= {};
SplineMuscle_CreateElement elem4 (NAME1=__NAME__,NAME2=Node3)= {};
#endif
#if CREATE_ELEMENTS >= 5
CreateMuscleElement elem5 (NAME1=__NAME__,NAME2=Node4)= {};
SplineMuscle_CreateElement elem5 (NAME1=__NAME__,NAME2=Node4)= {};
#endif
#if CREATE_ELEMENTS >= 6
CreateMuscleElement elem6 (NAME1=__NAME__,NAME2=Node5)= {};
SplineMuscle_CreateElement elem6 (NAME1=__NAME__,NAME2=Node5)= {};
#endif
#if CREATE_ELEMENTS >= 7
CreateMuscleElement elem7 (NAME1=__NAME__,NAME2=Node6)= {};
SplineMuscle_CreateElement elem7 (NAME1=__NAME__,NAME2=Node6)= {};
#endif
#if CREATE_ELEMENTS >= 8
CreateMuscleElement elem8 (NAME1=__NAME__,NAME2=Node7)= {};
SplineMuscle_CreateElement elem8 (NAME1=__NAME__,NAME2=Node7)= {};
#endif
#if CREATE_ELEMENTS >= 9
CreateMuscleElement elem9 (NAME1=__NAME__,NAME2=Node8)= {};
SplineMuscle_CreateElement elem9 (NAME1=__NAME__,NAME2=Node8)= {};
#endif
#if CREATE_ELEMENTS >= 10
CreateMuscleElement elem10 (NAME1=__NAME__,NAME2=Node9)= {};
SplineMuscle_CreateElement elem10 (NAME1=__NAME__,NAME2=Node9)= {};
#endif
#if CREATE_ELEMENTS >= 11
CreateMuscleElement elem11 (NAME1=__NAME__,NAME2=Node10)= {};
SplineMuscle_CreateElement elem11 (NAME1=__NAME__,NAME2=Node10)= {};
#endif
#if CREATE_ELEMENTS >= 12
CreateMuscleElement elem12 (NAME1=__NAME__,NAME2=Node11)= {};
SplineMuscle_CreateElement elem12 (NAME1=__NAME__,NAME2=Node11)= {};
#endif
#if CREATE_ELEMENTS >= 13
CreateMuscleElement elem13 (NAME1=__NAME__,NAME2=Node12)= {};
SplineMuscle_CreateElement elem13 (NAME1=__NAME__,NAME2=Node12)= {};
#endif
#if CREATE_ELEMENTS >= 14
CreateMuscleElement elem14 (NAME1=__NAME__,NAME2=Node13)= {};
SplineMuscle_CreateElement elem14 (NAME1=__NAME__,NAME2=Node13)= {};
#endif
#if CREATE_ELEMENTS >= 15
CreateMuscleElement elem15 (NAME1=__NAME__,NAME2=Node14)= {};
SplineMuscle_CreateElement elem15 (NAME1=__NAME__,NAME2=Node14)= {};
#endif
#if CREATE_ELEMENTS >= 16
CreateMuscleElement elem16 (NAME1=__NAME__,NAME2=Node15)= {};
SplineMuscle_CreateElement elem16 (NAME1=__NAME__,NAME2=Node15)= {};
#endif
#if CREATE_ELEMENTS >= 17
CreateMuscleElement elem17 (NAME1=__NAME__,NAME2=Node16)= {};
SplineMuscle_CreateElement elem17 (NAME1=__NAME__,NAME2=Node16)= {};
#endif
#if CREATE_ELEMENTS >= 18
CreateMuscleElement elem18 (NAME1=__NAME__,NAME2=Node17)= {};
SplineMuscle_CreateElement elem18 (NAME1=__NAME__,NAME2=Node17)= {};
#endif
#if CREATE_ELEMENTS >= 19
CreateMuscleElement elem19 (NAME1=__NAME__,NAME2=Node18)= {};
SplineMuscle_CreateElement elem19 (NAME1=__NAME__,NAME2=Node18)= {};
#endif
#if CREATE_ELEMENTS >= 20
CreateMuscleElement elem20 (NAME1=__NAME__,NAME2=Node19)= {};
SplineMuscle_CreateElement elem20 (NAME1=__NAME__,NAME2=Node19)= {};
#endif
#if CREATE_ELEMENTS >= 21
CreateMuscleElement elem21 (NAME1=__NAME__,NAME2=Node20)= {};
SplineMuscle_CreateElement elem21 (NAME1=__NAME__,NAME2=Node20)= {};
#endif
#if CREATE_ELEMENTS >= 22
CreateMuscleElement elem22 (NAME1=__NAME__,NAME2=Node21)= {};
SplineMuscle_CreateElement elem22 (NAME1=__NAME__,NAME2=Node21)= {};
#endif
#if CREATE_ELEMENTS >= 23
CreateMuscleElement elem23 (NAME1=__NAME__,NAME2=Node22)= {};
SplineMuscle_CreateElement elem23 (NAME1=__NAME__,NAME2=Node22)= {};
#endif
#if CREATE_ELEMENTS >= 24
CreateMuscleElement elem24 (NAME1=__NAME__,NAME2=Node23)= {};
SplineMuscle_CreateElement elem24 (NAME1=__NAME__,NAME2=Node23)= {};
#endif
#if CREATE_ELEMENTS >= 25
CreateMuscleElement elem25 (NAME1=__NAME__,NAME2=Node24)= {};
SplineMuscle_CreateElement elem25 (NAME1=__NAME__,NAME2=Node24)= {};
#endif
#if CREATE_ELEMENTS >= 26
CreateMuscleElement elem26 (NAME1=__NAME__,NAME2=Node25)= {};
SplineMuscle_CreateElement elem26 (NAME1=__NAME__,NAME2=Node25)= {};
#endif
#if CREATE_ELEMENTS >= 27
CreateMuscleElement elem27 (NAME1=__NAME__,NAME2=Node26)= {};
SplineMuscle_CreateElement elem27 (NAME1=__NAME__,NAME2=Node26)= {};
#endif
#if CREATE_ELEMENTS >= 28
CreateMuscleElement elem28 (NAME1=__NAME__,NAME2=Node27)= {};
SplineMuscle_CreateElement elem28 (NAME1=__NAME__,NAME2=Node27)= {};
#endif
#if CREATE_ELEMENTS >= 29
CreateMuscleElement elem29 (NAME1=__NAME__,NAME2=Node28)= {};
SplineMuscle_CreateElement elem29 (NAME1=__NAME__,NAME2=Node28)= {};
#endif
#if CREATE_ELEMENTS >= 30
CreateMuscleElement elem30 (NAME1=__NAME__,NAME2=Node29)= {};
SplineMuscle_CreateElement elem30 (NAME1=__NAME__,NAME2=Node29)= {};
#endif
#if CREATE_ELEMENTS >= 31
CreateMuscleElement elem31 (NAME1=__NAME__,NAME2=Node30)= {};
SplineMuscle_CreateElement elem31 (NAME1=__NAME__,NAME2=Node30)= {};
#endif
#if CREATE_ELEMENTS >= 32
CreateMuscleElement elem32 (NAME1=__NAME__,NAME2=Node31)= {};
SplineMuscle_CreateElement elem32 (NAME1=__NAME__,NAME2=Node31)= {};
#endif
#if CREATE_ELEMENTS >= 33
CreateMuscleElement elem33 (NAME1=__NAME__,NAME2=Node32)= {};
SplineMuscle_CreateElement elem33 (NAME1=__NAME__,NAME2=Node32)= {};
#endif
#if CREATE_ELEMENTS >= 34
CreateMuscleElement elem34 (NAME1=__NAME__,NAME2=Node33)= {};
SplineMuscle_CreateElement elem34 (NAME1=__NAME__,NAME2=Node33)= {};
#endif
#if CREATE_ELEMENTS >= 35
CreateMuscleElement elem35 (NAME1=__NAME__,NAME2=Node34)= {};
SplineMuscle_CreateElement elem35 (NAME1=__NAME__,NAME2=Node34)= {};
#endif
#if CREATE_ELEMENTS >= 36
CreateMuscleElement elem36 (NAME1=__NAME__,NAME2=Node35)= {};
SplineMuscle_CreateElement elem36 (NAME1=__NAME__,NAME2=Node35)= {};
#endif
#if CREATE_ELEMENTS >= 37
CreateMuscleElement elem37 (NAME1=__NAME__,NAME2=Node36)= {};
SplineMuscle_CreateElement elem37 (NAME1=__NAME__,NAME2=Node36)= {};
#endif
#if CREATE_ELEMENTS >= 38
CreateMuscleElement elem38 (NAME1=__NAME__,NAME2=Node37)= {};
SplineMuscle_CreateElement elem38 (NAME1=__NAME__,NAME2=Node37)= {};
#endif
#if CREATE_ELEMENTS >= 39
CreateMuscleElement elem39 (NAME1=__NAME__,NAME2=Node38)= {};
SplineMuscle_CreateElement elem39 (NAME1=__NAME__,NAME2=Node38)= {};
#endif


Expand Down
Loading

0 comments on commit 3649fbb

Please sign in to comment.