public void NormalizingComplex()
        {
            var v1       = PointType.Vector(1, 2, 3);
            var expected = PointType.Vector(1 / Math.Sqrt(14), 2 / Math.Sqrt(14), 3 / Math.Sqrt(14));

            Assert.Equal(expected, v1.Normalize());
        }
        public void NormalizingSimple()
        {
            var v1       = PointType.Vector(4, 0, 0);
            var expected = PointType.Vector(1, 0, 0);

            Assert.Equal(expected, v1.Normalize());
        }
        public void MagnitudeNeg123()
        {
            var v1       = PointType.Vector(-1, -2, -3);
            var expected = Math.Sqrt(14);

            Assert.Equal(expected, v1.Magnetude());
        }
        public void MagnitudeZ1()
        {
            var v1       = PointType.Vector(0, 0, 1);
            var expected = 1;

            Assert.Equal(expected, v1.Magnetude());
        }
        public void DotProduct()
        {
            var v1       = PointType.Vector(1, 2, 3);
            var v2       = PointType.Vector(2, 3, 4);
            var expected = 20;

            Assert.Equal(expected, PointType.DotProduct(v1, v2));
        }
        public void SubstractVectorFromZeroVector()
        {
            var v1  = PointType.Vector(0, 0, 0);
            var v2  = PointType.Vector(1, -2, 3);
            var v   = PointType.Vector(-1, 2, -3);
            var sub = v1 - v2;

            Assert.Equal(v, sub);
            Assert.True(sub.IsVector);
        }
        public void SubstractTwoVectors()
        {
            var v1  = PointType.Vector(3, 2, 1);
            var v2  = PointType.Vector(5, 6, 7);
            var v   = PointType.Vector(-2, -4, -6);
            var sub = v1 - v2;

            Assert.Equal(v, sub);
            Assert.True(sub.IsVector);
        }
        public void SubstractVectorFromPoint()
        {
            var p1  = PointType.Point(3, 2, 1);
            var v2  = PointType.Vector(5, 6, 7);
            var p   = PointType.Point(-2, -4, -6);
            var sub = p1 - v2;

            Assert.Equal(p, sub);
            Assert.True(sub.IsPoint);
        }
        public void SubstractTwoPoints()
        {
            var p1  = PointType.Point(3, 2, 1);
            var p2  = PointType.Point(5, 6, 7);
            var v   = PointType.Vector(-2, -4, -6);
            var sub = p1 - p2;

            Assert.Equal(v, sub);
            Assert.True(sub.IsVector);
        }
        public void CrossProduct()
        {
            var v1        = PointType.Vector(1, 2, 3);
            var v2        = PointType.Vector(2, 3, 4);
            var expected1 = PointType.Vector(-1, 2, -1);
            var expected2 = PointType.Vector(1, -2, 1);

            Assert.Equal(expected1, PointType.CrossProduct(v1, v2));
            Assert.Equal(expected2, PointType.CrossProduct(v2, v1));
        }
Exemple #11
0
        protected override PointType LocalNormalAt(PointType point, Intersection hit = null)
        {
            var dist = point.X * point.X + point.Z * point.Z;

            if (dist < 1 && point.Y >= Maximum - EPSILON)
            {
                return(PointType.Vector(0, 1, 0));
            }

            if (dist < 1 && point.Y <= Minimum + EPSILON)
            {
                return(PointType.Vector(0, -1, 0));
            }

            return(PointType.Vector(point.X, 0, point.Z));
        }
Exemple #12
0
        private void CalculatePath()
        {
            DrawCanvas.Children.Clear();

            var proj = new obj.Projectile(
                PointType.Point(0, 1, 0),
                PointType.Vector(1, 1, 0).Normalize() * inc);
            var env = new obj.Environment(
                PointType.Vector(0, -0.1, 0),
                PointType.Vector(-0.01, 0, 0));

            foreach (var coord in obj.Projectile.GetTick(env, proj))
            {
                DrawCircle(coord.X, coord.Y);
            }
        }
Exemple #13
0
        protected override PointType LocalNormalAt(PointType point, Intersection hit = null)
        {
            var maxC = Max(Math.Abs(point.X), Math.Abs(point.Y), Math.Abs(point.Z));

            if (maxC == Math.Abs(point.X))
            {
                return(PointType.Vector(point.X, 0, 0));
            }
            if (maxC == Math.Abs(point.Y))
            {
                return(PointType.Vector(0, point.Y, 0));
            }
            if (maxC == Math.Abs(point.Z))
            {
                return(PointType.Vector(0, 0, point.Z));
            }

            throw new Exception("No normal found");
        }
 protected override PointType LocalNormalAt(PointType localPoint, Intersection hit = null)
 {
     return(PointType.Vector(localPoint.X, localPoint.Y, localPoint.Z));
 }
Exemple #15
0
 protected override PointType LocalNormalAt(PointType localPoint, Intersection hit = null)
 => PointType.Vector(0, 1, 0);