Copy link to clipboard
Copied
this may seem trivial, but vector mathematics is not my strong suit.
if I have a vector between point A and point B, how do I shorten it (or lengthen it), but maintian a center point between A and B, like this
A------------B old vector
A -------- B new vector or
--A------------B-- another new vector
Copy link to clipboard
Copied
Vectors don't really have a position, just length and direction. What are you trying to do exactly?
Dan
Copy link to clipboard
Copied
Hey Dan,
I have this expression that disperses layers in a comp between 2 nulls; so the first layer will get position of null 1, the last layer gets position of null 2 and all layers in between get evenly dispersed along a line between them.
what i am trying to figure out is a way to lengthen or shorten the line between the nulls. the position expression on each of the layers looks like this (the 2 nulls are the last 2 layers in the comp)
n = thisComp.numLayers;
v1 = thisComp.layer(n-1).position;
v2 = thisComp.layer(n).position;
if (index == 1){
v1
}else if (index == n-2){
v2
}else{
v1 + (v2 - v1)*((index-1)/(n-3))
}
Mike
Copy link to clipboard
Copied
This should do it:
offset = 25; // positive makes line longer
n = thisComp.numLayers;
v1 = thisComp.layer(n-1).position;
v2 = thisComp.layer(n).position;
v = normalize(v2 - v1)*offset;
v2 += v;
v1 -= v;
if (index == 1){
v1
}else if (index == n-2){
v2
}else{
v1 + (v2 - v1)*((index-1)/(n-3))
}
Dan
Copy link to clipboard
Copied
Awesome! thanks Dan, this is exactly what I needed.
Mike