Notifications
Clear all

[Closed] find proper rotation value in a hierarchy

Hi there

for some animation test i need to find a proper rotation value for each plane here the scene

objAr = #()
 p1 = plane name:"p1"	length:26 width:26 pos:[13,0,0] lengthsegs:0 widthsegs:0 wirecolor:blue
 p1.pivot =[0,0,0] ; append objAr p1 	
 p2 = copy p1 pos:[26,0,0]; rotate p2 (angleaxis -90 [0,1,0])  ; p2.parent = objAr[objAr.count] ; append objAr p2 
 p3 = copy p1 pos:[26,0,26]; p3.parent = objAr[objAr.count]	; append objAr p3 
 p4 = copy p1 pos:[26*2,0,26]; rotate p4 (angleaxis 90 [0,1,0]) ;p4.parent = objAr[objAr.count] ; append objAr p4 		
 p5 = copy p1 pos:[26*2,0,0]; p5.parent = objAr[objAr.count]	; append objAr p5 	
 p6 = copy p1 pos:[26*3,0,0]; p6.parent = objAr[objAr.count]	; append objAr p6 ; rotate p6 (angleaxis 90 [0,1,0]) 
 p7 = copy p1 pos:[26*3,0,-26]; p7.parent = objAr[objAr.count] ; append objAr p7 ; rotate p7 (angleaxis 180 [0,1,0]) 	
 p8 = copy p7 pos:[26*2,0,-26]; p8.parent = objAr[objAr.count] ; append objAr p8 ; rotate p8 (angleaxis 90 [0,1,0]) 	

what i like to do is

at time 0 with animate on (rotate p8 (angleaxis 0 [0,1,0]))
 at time 10 with animate on (rotate p8 (angleaxis -270  [0,1,0]))   

or

at time 0 with animate on (rotate p5 (angleaxis 0 [0,1,0]))
 at time 10 with animate on (rotate p5 (angleaxis -90  [0,1,0]))	

my problem is to find the proper rotation value for each plane i mean the -270 for p8 and -90 for p5 in the example and so forth. here it is my try

-----------
 totRot = in coordsys parent ($.rotation).angle
 theshakesh = ($.parent.rotation).angle		
 AddRot = 180 - totRot	
 
 at time 0 with animate on (rotate $ (angleaxis 0 [0,1,0]))
 at time 10 with animate on
 (	
 if totRot >= 180 then ( AddRot = 180 - totRot ; (rotate $ (angleaxis AddRot  [0,1,0])))
 else if theshakesh <= 0 then (rotate $ (angleaxis -totRot  [0,1,0]))	
 else ( rotate $ (angleaxis -180  [0,1,0]) ; rotate $ (angleaxis -AddRot  [0,1,0])   )	
 )	

it works for p7,p6,p4,p3,p2 but not for the p5 and p8 .
I would be grateful for any help or any better way.