Reputation: 27
I'm trying to find value for a point within a triangle or square. By "value" I do not mean coordinates. Suppose there is a value (number) assigned to each node of the square/triangle. The square/triangle is on a plane. How can I interpolate values to find out the value of the point inside.
I don't want to try the bilinear interpolation since that requires for me to know exactly which plane we are in. This plane is not in x-y or y-z or x-z. This plane can be a sloped plane in 3D. (not warped)
Thank you in advance for the help.
Upvotes: 0
Views: 132
Reputation: 80325
Any rectandle or triangle might be interpolated using one vertex (here A
) and two vectors of adjacent sides (here AB = B - A, AC = C - A
)
P(u, v) = A + AB * u + AC * v
Parameters u,v
lie in range 0..1
, also for triangle their sum should not exceed 1
This representation is suitable for any plane orientation.
For reference:
AB.x = B.x - A.x etc
fourth vertex of rectangle is:
D = A + AB * 1 + AC * 1
middle of rectangle:
M = A + AB * 0.5 + AC * 0.5
middle of BC side in triangle:
mBC = A + AB * 0.5 + AC * 0.5
median intersection point in triangle:
cT = A + AB * 0.5 * 2/3 + AC * 0.5 * 2/3
Upvotes: 1