public void TestRotateLikeZVector() { Point3 norm; Random rand = new Random(); for(int i = 0x00; i < TestParameters.PointTest; i++) { double x = 200.0*rand.NextDouble()-100.0d; double y = 200.0*rand.NextDouble()-100.0d; norm = new Point3(0.0d, 0.0d, 1.0d); double rinv = 1.0d/Math.Sqrt(x*x+y*y+1.0d); norm.RotateLikeZVector(x, y); Assert.IsTrue(Math.Abs(norm.X-x*rinv) <= Math.Sqrt(Maths.GlobalEpsilon)); Assert.IsTrue(Math.Abs(norm.Y-y*rinv) <= Math.Sqrt(Maths.GlobalEpsilon)); Assert.IsTrue(Math.Abs(norm.Z-rinv) <= Math.Sqrt(Maths.GlobalEpsilon)); } }
public void TweakNormal(Point3 tu, Point3 normal, Point3 bumpx, Point3 bumpy) { int y = Maths.Border(0x00, (int)Math.Round(Height*tu.Y), Height-0x01); int x = Maths.Border(0x00, (int)Math.Round(Width*tu.X), Width-0x01); int x0 = (x+Width-0x01)%Width; int y0 = ((y+Height-0x01)%Height)*Width; y *= Width; double xdiff = ((int)(Pixel[y+x]&0xff)-(int)(Pixel[y+x0]&0xff))/255.0d; double ydiff = ((int)(Pixel[y+x]&0xff)-(int)(Pixel[y0+x]&0xff))/255.0d; normal.RotateLikeZVector(xdiff, ydiff); }