public PatternsTest(ITestOutputHelper testOutputHelper)
        {
            this.testOutputHelper = testOutputHelper;

            var ci = new CultureInfo("en-us");

            Thread.CurrentThread.CurrentCulture   = ci;
            Thread.CurrentThread.CurrentUICulture = ci;

            matrix["identity_matrix"] = MatrixOperations.Identity(4);
            colors["white"]           = Tuple4.Vector(1.0, 1.0, 1.0);
            colors["black"]           = Tuple4.Vector(0.0, 0.0, 0.0);
        }
Exemplo n.º 2
0
        protected override Tuple4 GetBaseNormal(IFigure figure, Tuple4 pointOnSurface, double u, double v)
        {
            var d = pointOnSurface.X * pointOnSurface.X + pointOnSurface.Z * pointOnSurface.Z;

            if ((d < 1) && (pointOnSurface.Y + Constants.Epsilon >= Maximum))
            {
                return(Tuple4.Vector(0, 1, 0));
            }
            else if ((d < 1) && (pointOnSurface.Y - Constants.Epsilon <= Minimum))
            {
                return(Tuple4.Vector(0, -1, 0));
            }

            return(Tuple4.Vector(pointOnSurface.X, 0.0, pointOnSurface.Z));
        }
Exemplo n.º 3
0
        public Tuple4 TransformObjectNormalToWorldNormal(Tuple4 normal)
        {
            if (inverseTransposeTransformation != null)
            {
                normal = MatrixOperations.Geometry3D.Transform(inverseTransposeTransformation, normal);
                if (normal.W != 0.0)
                {
                    normal = Tuple4.Vector(normal.X, normal.Y, normal.Z);
                }
            }

            normal = Tuple4.Normalize(normal);

            if (Parent != null)
            {
                normal = Parent.TransformObjectNormalToWorldNormal(normal);
            }

            return(normal);
        }
 public void Then_triangle_e2(string id, double x, double y, double z)
 {
     Assert.Equal(Tuple4.Vector(x, y, z), figure[id].E2);
 }
 protected override Tuple4 GetBaseNormal(IFigure figure, Tuple4 pointOnSurface, double u, double v)
 {
     return(Tuple4.Vector(pointOnSurface.X, pointOnSurface.Y, pointOnSurface.Z));
 }
 public void When_normal_to_world(string a, string s, double t1, double t2, double t3)
 {
     tuple[a] = ((BaseFigure)figure[s]).TransformObjectNormalToWorldNormal(Tuple4.Vector(t1, t2, t3));
 }
 public void Then_saved_ray_direction(string a, double t1, double t2, double t3)
 {
     Assert.Equal(Tuple4.Vector(t1, t2, t3), ((TestFigure)figure[a]).SavedRay.dir);
 }
Exemplo n.º 8
0
 public void Then_vector(string a, double t1, double t2, double t3)
 {
     Assert.Equal(Tuple4.Vector(t1, t2, t3), tuple[a]);
 }
Exemplo n.º 9
0
        public void Then_color(string id, double r, double g, double b)
        {
            var c = colors[id];

            Assert.Equal(Tuple4.Vector(r, g, b), c);
        }
 public void Then_hit_reflectv(double x, double y, double z)
 {
     Assert.Equal(Tuple4.Vector(x, y, z), hit[ComputationsId].ReflectionVector);
 }
 public void Given_ray(string id,
                       double p1, double p2, double p3,
                       double v1, double v2, double v3)
 {
     ray[id] = new Ray(Tuple4.Point(p1, p2, p3), Tuple4.Vector(v1, v2, v3));
 }
Exemplo n.º 12
0
 public void Normalize_vector(string id, double t1, double t2, double t3)
 {
     tuple.Add(id, Tuple4.Normalize(Tuple4.Vector(t1, t2, t3)));
 }
Exemplo n.º 13
0
 public void Then_parser_normal(string id, int i, double x, double y, double z)
 {
     Assert.Equal(Tuple4.Vector(x, y, z), parser[id].Normals[i - 1]);
 }
 public void Then_hit_eyev(double x, double y, double z)
 {
     Assert.Equal(Tuple4.Vector(x, y, z), hit[ComputationsId].SurfaceNormal);
 }
Exemplo n.º 15
0
 private Tuple4 ReadNormal(string[] parts)
 {
     return(Tuple4.Vector(ReadDouble(parts[1]), ReadDouble(parts[2]), ReadDouble(parts[3])));
 }
 public void Vector_id(string id, double t1, double t2, double t3)
 {
     tuple[id] = Tuple4.Vector(t1, t2, t3);
 }
 public void Then_pattern_at_color(string id, double x, double y, double z, double r, double g, double b)
 {
     Assert.Equal(Tuple4.Vector(r, g, b), patterns[id].GetColor(Tuple4.Point(x, y, z)));
 }