Textured polygon in D3D

BlitzMax Forums/BlitzMax Programming/Textured polygon in D3D

Golden! This works great! One question tough...
I'm using these functions to calculate the UV coordinates from the vertices..
	Function GetU:Float(x:Float,y:Float)
		Return x/Sqr(x*x + y*y)
	EndFunction
	
	Function GetV:Float(x:Float, y:Float)
		Return y/Sqr(x*x + y*y)
	EndFunction


However, the texture is stretched when the polygon is aligned in certain ways. Is there a better way to calculate this?