-
confused about parenting (!) toWorld doesn’t fix things
hi, I have 3 nulls named P1,P2 and P3 evenly distributed on my composition.
P3 is parented to P2. P2 is parented to P1. P1 has no parent. All the nulls have scale 100%. All have anchorPoint [0,0].
So I made a fn to calculate distances between them and although the nulls are evenly spaced on screen the two calculated distances are different by a factor of about 7. Using toWorld makes no difference. Changing from position to anchorPoint makes no difference.
If I move P3 over P2 it’s position in the timeline goes to zero but it’s distance calculated by the fn goes up to about right. If I unparent P2 from P1 this too causes the distance to go up and again looks like it becomes right.
Can anyone explain how to correctly get the world position of a chain of parented nulls in CS4?
Thanks
//this gives wildly wrong results (400 and 73)
D12= getLength(p1.transform.position,toWorld(p2.transform.position));
D23= getLength(toWorld(p2.transform.position),toWorld(p3.transform.position));//shouldn't have to do this since P1 is an orphan? and it isn't any better
D12= getLength(toWorld(p1.transform.position),toWorld(p2.transform.position));//this gives zero for the distance
D23= getLength(toWorld(p2.transform.anchorPoint),toWorld(p3.transform.anchorPoint));I've tested this...
function getLength(p1,p2) {
dx=p1[0] - p2[0];
dy=p1[1] - p2[1];
l=Math.sqrt(dx*dx+dy*dy);
return l;
}