Cage opened this issue on Dec 20, 2006 · 1232 posts
Spanki posted Thu, 28 December 2006 at 4:34 PM
Point 4 is 25% the distance from vertex C to vert B
Point 1 is the same distance from point C as point 4 is
Point 2 is equal distant from A, B and C
Point 3 is half-way between A and B
Ok, given the above, trying to come up with the weighting algorythm... we want to make sure that:
Point 4 is not affected by A (A's weight should be 0.0 for point 4)
Point 4 should be affected more by C than by B (.75 weight for C, .25 weight for B).
Point 1 should be affected by point C just as much as point 4 is, but is also affected by both A and B
Point 2 should be equallly affected by movements in A, B and/or C (weights for A,B and C should all be 0.33333 repeating, or 33 and a third percent)
Point 3 should not be affected by C, but is equally affected by both A and B
...it looks like the algorythm that solves all of the above conditions is that the weight for a particular vertex (A, B or C) is determined by 1.0 minus the distance of the intersection point from the vertex, relative to the distance from that vertex to the edge of the remaining vertices of the polygon, along the line determined by the vertex and the intersection.
So if:
distance to edge along the line between vertex and interesection point is EdgeDist
distance from vertex to intersection point is **ISectDist
**weight for this vertex is calculated as:
weight = 1.0 - (ISectDist divided by EdgeDist)
So for example, let's look at point 4 and calculate the weights for each vertex, with the above information...
Vertex A:
Let's assume the distance from A to the intersection ( ISectDist) is 8.5 ....note that the distance from A to the edge between C and B along the line between A and 4 (EdgeDist) is exactly the same.. 8.5 so...
WeightA = 1.0 - (8.5 divided by 8.5) or 1.0 - (1.0) = 0.0 ...so the weight for vertex A for intersection point 4 is 0.0 which is exactly what we want.
Vertex B:
Let's assume an EdgeDist value of 8.0 (the distance from B to the line between A and C, along the line generated between B and 4). As stated above, point 4 is 25% the distance from C towards B, so conversely, that would make IsectDist = 6.0 (75% of 8.0) so...
WeightB = 1.0 - (6.0 divided by 8.0) or 1.0 - (0.75) = 0.25 ...so the weight for vertex B for intersection point 4 is 0.25 which is as expected.
Vetex C:
This is basically the oposite of the vertex B calculations...
WeightC = 1.0 - (2.0 divided by 8.0) or 1.0 - (0.25) = 0.75 ...also expected.
...you can run the numbers on the other situations, but I think they'll hold up fine.
Now, this works fine for triangles, but what happens with quads or n-gons? ... I hadn't thought about that yet :) so I'm hoping it's a natural extension of the above.
Cinema4D Plugins (Home of Riptide, Riptide Pro, Undertow, Morph Mill, KyamaSlide and I/Ogre plugins) Poser products Freelance Modelling, Poser Rigging, UV-mapping work for hire.