Microsoft DirectX 8.1 (Visual Basic) |
Returns a point in Barycentric coordinates, using the specified 3-D vectors.
D3DXVec3BaryCentric( _ VOut As D3DVECTOR, _ V1 As D3DVECTOR, _ V2 As D3DVECTOR, _ V3 As D3DVECTOR, _ f As Single, _ g As Single)
If the function fails, an error is raised and Err.Number can be set to one of the following values.
D3DERR_INVALIDCALL |
D3DERR_OUTOFVIDEOMEMORY |
For information on trapping errors, see the Microsoft® Visual Basic® Error Handling topic.
The D3DXVec3BaryCentric function provides a way to understand points in and around a triangle, independent of where the triangle is actually located. This function returns the resulting point by using the following equation: V1 + f(V2-V1) + g(V3-V1).
Any point in the plane V1V2V3 can be represented by the Barycentric coordinate (f,g).The parameter f controls how much V2 gets weighted into the result, and the parameter g controls how much V3 gets weighted into the result. Lastly, 1-f-g controls how much V1 gets weighted into the result.
Note the following relations.
Barycentric coordinates are a form of general coordinates. In this context, using Barycentric coordinates simply represents a change in coordinate systems; what holds true for Cartesian coordinates holds true for Barycentric coordinates.