public Segment[] Generate()
        {
            Segment[] children = new Segment[4];

            PVector v = PVector.Sub(b, a);

            v.Div(3);

            // Segment 0
            PVector b1 = PVector.Add(a, v);

            children[0] = new Segment(a, b1);

            // Segment 3
            PVector a1 = PVector.Sub(b, v);

            children[3] = new Segment(a1, b);

            v.Rotate((float)-Math.PI / 3);
            PVector c = PVector.Add(b1, v);

            // Segment 2
            children[1] = new Segment(b1, c);
            // Segment 3
            children[2] = new Segment(c, a1);
            return(children);
        }
Ejemplo n.º 2
0
        public void ShouldDivideAllComponentsByTheScalarAndReturnItself()
        {
            float   x       = 1.2f;
            float   y       = 3.456f;
            float   z       = 7.8901f;
            float   scalar  = 3.58f;
            PVector vectorA = new PVector(x, y, z);

            PVector returnedVector = vectorA.Div(scalar);

            Assert.Equal(returnedVector, vectorA);

            Assert.Equal(x / scalar, vectorA.X);
            Assert.Equal(y / scalar, vectorA.Y);
            Assert.Equal(z / scalar, vectorA.Z);
        }
Ejemplo n.º 3
0
        public void ShouldReturnDividedVectorWhithoutChangingOriginalVector()
        {
            float   x       = 1.2f;
            float   y       = 3.456f;
            float   z       = 7.8901f;
            float   scalar  = 3.58f;
            PVector vectorA = new PVector(x, y, z);

            PVector returnedVector = PVector.Div(vectorA, scalar);

            Assert.Equal(x, vectorA.X);
            Assert.Equal(y, vectorA.Y);
            Assert.Equal(z, vectorA.Z);

            Assert.Equal(x / scalar, returnedVector.X);
            Assert.Equal(y / scalar, returnedVector.Y);
            Assert.Equal(z / scalar, returnedVector.Z);
        }