Exemple #1
0
        public void DotProduct()
        {
            IVector <DoubleComponent> Test1 = MatrixFactory <DoubleComponent> .CreateVector3D(10, 1, 2);

            IVector <DoubleComponent> Test2 = MatrixFactory <DoubleComponent> .CreateVector3D(1, 0, 0);

            DoubleComponent DotResult = Test2.Dot(Test1);

            Assert.IsTrue(DotResult.Equals(10));
        }
Exemple #2
0
        public IRay GetRefractionRay()
        {
            IVector v    = this.Ray.Direction.Negate();
            IVector n    = this.Normal;
            float   cosi = v.Dot(n);
            float   nint;

            if (this.InComing)
            {
                nint = 1.0f / this.IntersectShape.Material.IndexOfRefraction;
            }
            else
            {
                nint = this.IntersectShape.Material.IndexOfRefraction;
            }
            float cost = (float)Math.Sqrt(1.0f - nint * nint * (1 - cosi * cosi));

            return(new Ray(this.Intersection, n.Times(nint * cosi - cost).Minus(v.Times(nint))));
        }
Exemple #3
0
        public override IRayHit Intersect(IRay ray)
        {
            float denominator = this.Normal.Dot(ray.Direction);

            if (Math.Abs(denominator) > 0.0f)
            {
                IVector difference = this.Position.Minus(ray.Origin);

                float t = difference.Dot(this.Normal) / denominator;

                if (t > 0.0f)
                {
                    IVector intersectionPoint = ray.GetEndAt(t);

                    return(new RayHit(ray, this, this, this.Normal, intersectionPoint, t, false));
                }
            }

            return(null);
        }