Exemple #1
0
 private PVector GetNewDrawingPoint(PVector p, PVector next, int n)
 {
     var rnd = new Random(n*10);
     var rndx2 = new Random(n * 452);
     var rndy = new Random(n * 70);
     var rndy2 = new Random(n * 750);
     PVector direction = PVector.Sub(next, p);
     PVector newPosition = direction.Copy();
     newPosition.SetMag((GetRandomized(rnd, rndx2) - 0.5) * _BrushInfoService.XDispersion);
     PVector ymov = direction.Copy();
     ymov.RotateDegrees(90);
     ymov.SetMag((GetRandomized(rndy, rndy2) - 0.5) * _BrushInfoService.YDispersion);
     newPosition.Add(ymov);
     newPosition.Add(p);
     return newPosition;
 }
        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);
        }
Exemple #3
0
        public void ShouldAdd3ComponentsAndReturnItself()
        {
            PVector originalVector = new PVector(1, 3, 7);

            PVector addedVector = originalVector.Add(.2f, .456f, .8901f);

            Assert.Equal(1.2f, originalVector.X);
            Assert.Equal(3.456f, originalVector.Y);
            Assert.Equal(7.8901f, originalVector.Z);


            Assert.Equal(addedVector, originalVector);
            Assert.Equal(addedVector.X, originalVector.X);
            Assert.Equal(addedVector.Y, originalVector.Y);
            Assert.Equal(addedVector.Z, originalVector.Z);
        }
Exemple #4
0
        public void DrawCurve(PCurve curve, SKCanvas canv) {
            int drawnPoints = 0;
            var step = _BrushInfoService.XSpacing;
            var div = curve.DivideLength(step);
           
            float len = 0;
            for(int i = 0;i< div.Count - 1; i++)
            {

                DrawPoint(div[i], div[i + 1], canv, drawnPoints, CurvePositionKoeficient(len, curve.Length));
                drawnPoints++;
                len += PVector.DistanceBetween(div[i], div[i + 1]).ToFloat();
            }
            PVector vec = PVector.Sub(div.Last(), div.Count>1?div[div.Count - 2]:PVector.Add(div.Last(), new PVector(0,1)));
            vec.Add(div.Last());
            DrawPoint(div.Last(), vec, canv, drawnPoints, CurvePositionKoeficient(curve.Length, curve.Length));
            drawnPoints++;
        }
Exemple #5
0
        public void ShouldAddVectorAndReturnItself()
        {
            PVector originalVector       = new PVector(1, 3, 7);
            PVector vectorToSubtractFrom = new PVector(.2f, .456f, .8901f);

            PVector addedVector = originalVector.Add(vectorToSubtractFrom);


            Assert.Equal(1.2f, originalVector.X);
            Assert.Equal(3.456f, originalVector.Y);
            Assert.Equal(7.8901f, originalVector.Z);


            Assert.Equal(addedVector, originalVector);
            Assert.Equal(addedVector.X, originalVector.X);
            Assert.Equal(addedVector.Y, originalVector.Y);
            Assert.Equal(addedVector.Z, originalVector.Z);
        }
Exemple #6
0
        public void ShouldReturnAddedVectorWhithoutChangingOriginalVectors()
        {
            PVector vectorA = new PVector(1, 3, 7);

            PVector vectorB = new PVector(.2f, .456f, .8901f);

            PVector addedVector = PVector.Add(vectorA, vectorB);

            Assert.Equal(1.2f, addedVector.X);
            Assert.Equal(3.456f, addedVector.Y);
            Assert.Equal(7.8901f, addedVector.Z);;

            Assert.Equal(1, vectorA.X);
            Assert.Equal(3, vectorA.Y);
            Assert.Equal(7, vectorA.Z);

            Assert.Equal(.2f, vectorB.X);
            Assert.Equal(.456f, vectorB.Y);
            Assert.Equal(.8901f, vectorB.Z);
        }
Exemple #7
0
        public void ShouldAssignAddedVectorToTargetWhithoutChangingOriginalVectors()
        {
            PVector vectorA = new PVector(1, 3, 7);

            PVector vectorB = new PVector(.2f, .456f, .8901f);

            PVector targetVector = new PVector();

            PVector returnedVector = PVector.Add(vectorA, vectorB, targetVector);

            Assert.Equal(returnedVector, targetVector);

            Assert.Equal(1.2f, targetVector.X);
            Assert.Equal(3.456f, targetVector.Y);
            Assert.Equal(7.8901f, targetVector.Z);

            Assert.Equal(1f, vectorA.X);
            Assert.Equal(3f, vectorA.Y);
            Assert.Equal(7, vectorA.Z);

            Assert.Equal(.2f, vectorB.X);
            Assert.Equal(.456f, vectorB.Y);
            Assert.Equal(.8901f, vectorB.Z);
        }