[Closed] 8 Point FFD Equation
Anybody know the equation off the top of their head for a cubic FFD transformation of a given point within the domain?
well it isn’t so much an ‘equation’ as it is linearly transforming from one position to a new position?
I.e. in a 1D case, if you have a point on a given line (original lattice), measure the length of that line, measure the distance of the point to either end of the line. Now you stretch/compress that line (new lattice), measure the length of the line again. Divide the new length by the old length and you’ve got a multiplier to apply to the distance of your point to the end to get the new distance along the line – offset by the new position of the end (if changed).
Now do that for all 3 axes and you should be all set?
In the case of 2D here is what I came up with:
y = ((p0.y+p2.y)(%y) + (p3.y+p1.y)(%y))(%x) etc etc etc…
(Find the delta Y along both sides. Find the line between them and then find the delta X along that line… that should find it. But…
that all reduces to: (p0.y+p1.y+p2.y+p3.y)(%x)(%y)
Which works fine when %x == %y but not when %x,%y or %z are different so I must be doing it wrong.
I’m writing my own FFD transform. But for object positions instead of vertex positions.
I wrote a hack using a real FFD transform and an editable mesh. But it’s reallllllly crashy.
Ha! Stupid slaps self with trout
No wonder it didn’t make any sense. My equation for “0.x along line between two points” equation was COMPLETELY wrong.
I was just taking the old midpoint equation:
(x1 + x2)*.5
(y1 + y2)*.5
and trying to replace .5 with my own float. that won’t work!
Essentially all you need to do is get the weight of the object realtive to the points its near. So you could do this, get object ‘a’ get the lengths from it to all the other points, and normalize it in this space. eg.
A to B = 10 , A to C = 20 , A to D = 30 , total = 60,
now you need to get the inverse weight space to them, i do this by simple division:
60/10 = 6, 60/20 = 3, 60/30 = 2, total = 11
now i do standard division to get the multiplier each point onto A:
6/11 = .54 , 3/11 = .27 , 2/11 = .18
So A.pos = (B.pos * .54) + (C.pos * .27) + (D.pos * .18)
Here’s the basic formula, i encapsulated a lot of summations, but this could just be several loops.
where n is the number or points, v(i) is your point position and p is the objects position, and w(i) is the weight. The weights would have to be stored into an array.
Hmmm normalized weighting… that’s nice and elegant.
I took the brute force approach.
deltaXYZ = [0.5,0.5,0.5]
centerpoint = ((((((p0.pos)*(1-deltaXYZ.Z)+(p2.pos)*(deltaXYZ.Z))*(1-deltaXYZ.X)) + (((p1.pos)*(1-deltaXYZ.Z)+(p3.pos)*(deltaXYZ.Z))*(deltaXYZ.X)))*(1-deltaXYZ.Y)) + (((((p4.pos)*(1-deltaXYZ.Z)+(p6.pos)*(deltaXYZ.Z))*(1-deltaXYZ.X)) + (((p5.pos)*(1-deltaXYZ.Z)+(p7.pos)*(deltaXYZ.Z))*(deltaXYZ.X)))*(deltaXYZ.Y)))
point pos:centerpoint