Esempio n. 1
0
        public Triangle(PVector v1, PVector v2, PVector v3)
        {
            this.V1 = v1;
            this.V2 = v2;
            this.V3 = v3;

            Vertics = new PVector[3];
            Vertics[0] = v1;
            Vertics[1] = v2;
            Vertics[2] = v3;
        }
Esempio n. 2
0
        public static float GetDist(PVector p1, PVector p2)
        {
            float width = p1.X - p2.X;
            float height = p1.Y - p2.Y;
            float depth = p1.Z - p2.Z;

            float dist = (float)( Math.Sqrt(Math.Pow(width, 2) +
                                                Math.Pow(height, 2) +
                                                Math.Pow(depth, 2)) );

            return dist;
        }
Esempio n. 3
0
        public void ShouldReturnZeroIfOneVectorHasAllComponentsEqualsZero()
        {
            PVector vectorA       = new PVector(0, 0, 0);
            PVector vectorB       = new PVector(1, 1, 1);
            float   expectedTheta = 0f;

            float actualTheta = vectorA.AngleBetween(vectorB);


            Assert.Equal(expectedTheta, actualTheta);
            actualTheta = vectorB.AngleBetween(vectorA);
            Assert.Equal(expectedTheta, actualTheta);
        }
Esempio n. 4
0
        public void ShouldCalculateMagnitudeSquaredOfVector()
        {
            PVector originalVector   = new PVector(3, 4, 0);
            float   magnitudeSquared = originalVector.MagSq();

            Assert.Equal(25f, magnitudeSquared);


            originalVector   = new PVector(1, 2, 2);
            magnitudeSquared = originalVector.MagSq();

            Assert.Equal(9, magnitudeSquared);
        }
Esempio n. 5
0
        public void ShouldCalculateMagnitudeOfVector()
        {
            PVector originalVector = new PVector(3, 4, 0);
            float   magnitude      = originalVector.Mag();

            Assert.Equal(5f, magnitude);


            originalVector = new PVector(1, 2, 2);
            magnitude      = originalVector.Mag();

            Assert.Equal(3, magnitude);
        }
Esempio n. 6
0
    public Plane(PVector p0, PVector p1, PVector p2)
    {
        A = p0.y * (p1.z - p2.z) + p1.y * (p2.z - p0.z) + p2.y * (p0.z - p1.z);
        B = p0.z * (p1.x - p2.x) + p1.z * (p2.x - p0.x) + p2.z * (p0.x - p1.x);
        C = p0.x * (p1.y - p2.y) + p1.x * (p2.y - p0.y) + p2.x * (p0.y - p1.y);
        PVector norm = new PVector(A, B, C);

        norm.normalize();
        A = norm.x;
        B = norm.y;
        C = norm.z;
        D = -A * p0.x - B * p0.y - C * p0.z;
    }
Esempio n. 7
0
        public void ShouldSetComponentsFromAnotherVectorParamAndReturnVector()
        {
            PVector originalVector = new PVector(1, 2, 3);
            PVector paramVector    = new PVector(4, 5, 6);

            PVector resultVector = originalVector.Set(paramVector);

            Assert.Equal(originalVector, resultVector);

            Assert.Equal(4, originalVector.X);
            Assert.Equal(5, originalVector.Y);
            Assert.Equal(6, originalVector.Z);
        }
Esempio n. 8
0
        public void ShouldChangeMagnitudeIfActualMagnitudeIsGreaterThanMaxValue()
        {
            PVector vectorA           = new PVector(1, 2, 2); // Magnitude 3
            float   originalMagnitude = vectorA.Mag();
            float   maxMagnitude      = 2f;
            PVector limitedVector     = vectorA.Limit(maxMagnitude);
            float   newMagnitude      = limitedVector.Mag();

            Assert.Same(vectorA, limitedVector);
            Assert.Equal(3f, originalMagnitude);
            Assert.NotEqual(newMagnitude, originalMagnitude);
            Assert.Equal(maxMagnitude, newMagnitude);
        }
Esempio n. 9
0
 public void DrawPoint(PVector p, PVector next, SKCanvas canv, int n, float koef=1)
 {
     var npos = GetNewDrawingPoint(p, next,n);
     var newPosition = PVector.Sub(npos, p);
     newPosition.Mult(koef);
     newPosition.Add(p);
     
     var newOpacity = GetNewOpacity(n) * koef;
     var newScale = GetNewScale(n)*koef;
     var col = GetNewColor(n);
     var hardness = GetNewHardness(n);
     SKPaint shad = GetRadialPaint(col, newPosition, newScale, newOpacity, hardness);
     canv.DrawCircle(newPosition.X.ToFloat(), newPosition.Y.ToFloat(), newScale, shad);
 }
Esempio n. 10
0
        protected override void drawRectImpl(PVector position, float width, float heigth)
        {
            using (RectangleShape rectangle = new RectangleShape(new Vector2f(width, heigth)))
            {
                rectangle.Position         = toVector2f(position);
                rectangle.FillColor        = toColor(fillColor);
                rectangle.OutlineThickness = strokeWeight;
                rectangle.OutlineColor     = toColor(strokeColor);
                rectangle.Rotation         = Helpers.ConvertionHelper.RadiansToDegrees(transformation.Angle);
                window.Draw(rectangle);
            }

            surface.RefreshNeeded();
        }
Esempio n. 11
0
        public List <PVector> ApplyRuler(List <PVector> inputData)
        {
            var generatedData = CalculateData(inputData);
            var retVal        = new List <PVector>();

            for (int i = 0; i < inputData.Count; i++)
            {
                var vec = PVector.Sub(generatedData[i], inputData[1]);
                vec.Mult(RulerAffectWeight);
                vec.Add(inputData[i]);
                retVal.Add(vec);
            }
            return(retVal);
        }
Esempio n. 12
0
        public void ShouldCreateASameRandom3DUnitVectorFromGivenRandomObjectAndSetTarget()
        {
            Random  random    = new Random(1);
            PVector target    = new PVector();
            PVector vectorA   = PVector.Random3D(target, random);
            float   expectedX = -0.5410597f;
            float   expectedY = -0.83798015f;
            float   expectedZ = -0.07101854f;

            Assert.NotNull(vectorA);
            Assert.Same(target, vectorA);
            Assert.Equal(expectedX, vectorA.X);
            Assert.Equal(expectedY, vectorA.Y);
            Assert.Equal(expectedZ, vectorA.Z);
        }
Esempio n. 13
0
        public void ShouldSetMagnitude()
        {
            PVector vectorA             = new PVector(1, 2, 2); // Magnitude 3
            float   originalMagnitude   = vectorA.Mag();
            float   desiredNewMagnitude = 5f;
            PVector limitedVector       = vectorA.SetMag(desiredNewMagnitude);
            float   newMagnitude        = limitedVector.Mag();

            Assert.Same(vectorA, limitedVector);
            Assert.Equal(3f, originalMagnitude);
            Assert.NotEqual(originalMagnitude, newMagnitude);
            double roundingError = Math.Abs(desiredNewMagnitude - newMagnitude);

            Assert.True(roundingError < ROUNDING_ERROR);
        }
Esempio n. 14
0
        private List <PVector> SetRndPoint(int setPointNumber)
        {
            Random         rand      = new Random(3);
            List <PVector> pointList = new List <PVector>();

            for (int i = 0; i < setPointNumber; i++)
            {
                PVector vector = new PVector(
                    (float)rand.Next(1, 100) / 100.0f,
                    (float)rand.Next(1, 100) / 100.0f,
                    (float)rand.Next(1, 100) / 100.0f);
                pointList.Add(vector);
            }
            return(pointList);
        }
Esempio n. 15
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);
        }
Esempio n. 16
0
        public void ShouldSubtract3ComponentsAndReturnItself()
        {
            PVector originalVector = new PVector(1.2f, 3.456f, 7.8901f);

            PVector subtractedVector = originalVector.Sub(.2f, .456f, .8901f);

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


            Assert.Equal(subtractedVector, originalVector);
            Assert.Equal(subtractedVector.X, originalVector.X);
            Assert.Equal(subtractedVector.Y, originalVector.Y);
            Assert.Equal(subtractedVector.Z, originalVector.Z);
        }
Esempio n. 17
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;
 }
Esempio n. 18
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);
        }
Esempio n. 19
0
        public void ShouldThowExceptionIfNewMagnitudeIsZeroOrLower()
        {
            PVector vectorA           = new PVector(1, 2, 2); // Magnitude 3
            float   originalMagnitude = vectorA.Mag();

            Assert.Throws <ArgumentException>(
                "length",
                () => { PVector limitedVector = vectorA.SetMag(-0.001f); }
                );


            Assert.Throws <ArgumentException>(
                "length",
                () => { PVector limitedVector = vectorA.SetMag(0f); }
                );
        }
Esempio n. 20
0
        public Tetrahedron(PVector p1, PVector p2, PVector p3, PVector p4)
        {
            Vertices = new PVector[4];

            P1 = p1;
            Vertices[0] = p1;

            P2 = p2;
            Vertices[1] = p2;

            P3 = p3;
            Vertices[2] = p3;

            P4 = p4;
            Vertices[3] = p4;

            getCenterCircumcircle();
        }
Esempio n. 21
0
        public void ShouldReturnActualAngleOfVectorOnXYPlane()
        {
            PVector vectorA       = new PVector(1, 1, 2);
            float   theta         = vectorA.Heading(); // PI/4
            float   expectedTheta = (float)Math.PI / 4;

            Assert.Equal(expectedTheta, theta);

            vectorA.Set(1, 0);
            theta         = vectorA.Heading(); // 0
            expectedTheta = 0f;
            Assert.Equal(expectedTheta, theta);

            vectorA.Set(0, 1);
            theta         = vectorA.Heading(); // PI/2
            expectedTheta = (float)Math.PI / 2;
            Assert.Equal(expectedTheta, theta);
        }
Esempio n. 22
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);
        }
Esempio n. 23
0
        public void ShouldReturnNormalizedVectorWithoutChangingActrualVector()
        {
            PVector vectorA           = new PVector(3, 4, 5);
            PVector vectorACopy       = vectorA.Copy();
            float   originalMagnitude = vectorA.Mag();
            PVector targetVector      = new PVector(5, 5, 5);

            PVector normalizedVector = vectorA.Normalize(targetVector);

            //Vector A should not change
            Assert.Equal(originalMagnitude, vectorA.Mag());
            Assert.Equal(vectorACopy.X, vectorA.X);
            Assert.Equal(vectorACopy.Y, vectorA.Y);
            Assert.Equal(vectorACopy.Z, vectorA.Z);

            Assert.Same(normalizedVector, targetVector);
            Assert.NotEqual(1f, targetVector.Mag());
        }
Esempio n. 24
0
        public void ShouldSubtractVectorAndReturnItself()
        {
            PVector originalVector       = new PVector(1.2f, 3.456f, 7.8901f);
            PVector vectorToSubtractFrom = new PVector(.2f, .456f, .8901f);

            PVector subtractedVector = originalVector.Sub(vectorToSubtractFrom);


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


            Assert.Equal(subtractedVector, originalVector);
            Assert.Equal(subtractedVector.X, originalVector.X);
            Assert.Equal(subtractedVector.Y, originalVector.Y);
            Assert.Equal(subtractedVector.Z, originalVector.Z);
        }
Esempio n. 25
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);
        }
Esempio n. 26
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++;
        }
Esempio n. 27
0
        public void ShouldThrowExceptionIfIListSizeWereZeroOrHigherThenThree()
        {
            PVector originalVector = new PVector(1, 2, 3);

            float[] source1 = { };

            Assert.Throws <ArgumentException>(
                "source",
                () => { PVector resultVector = originalVector.Set(source1); }
                );

            float[] source4 = { 1, 2, 3, 4 };

            Assert.Throws <ArgumentException>(
                "source",
                () => { PVector resultVector = originalVector.Set(source4); }
                );
        }
Esempio n. 28
0
    //Paul Bourke, http://local.wasp.uwa.edu.au/~pbourke/geometry/planeline/
    PVector planeEdgeIntersection(HE_Edge e, Plane P)
    {
        PVector p0    = e.halfEdge.vert;
        PVector p1    = e.halfEdge.pair.vert;
        float   denom = P.A * (p0.x - p1.x) + P.B * (p0.y - p1.y) + P.C * (p0.z - p1.z);

        if ((denom < HE_Mesh.DELTA) && (denom > -HE_Mesh.DELTA))
        {
            return(null);
        }
        float u = (P.A * p0.x + P.B * p0.y + P.C * p0.z + P.D) / denom;

        if ((u < 0.0f) || (u > 1.0f))
        {
            return(null);
        }
        return(new PVector(p0.x + u * (p1.x - p0.x), p0.y + u * (p1.y - p0.y), p0.z + u * (p1.z - p0.z)));
    }
Esempio n. 29
0
    //returns 1 if p is on same side as normal, -1 if on opposite side, 0 if on the plane
    public float side(PVector p)
    {
        float tmp = A * p.x + B * p.y + C * p.z + D;

        if (tmp < -HE_Mesh.DELTA)
        {
            tmp = -1f;
        }
        else if (tmp > HE_Mesh.DELTA)
        {
            tmp = 1f;
        }
        else
        {
            tmp = 0f;
        }
        return(tmp);
    }
Esempio n. 30
0
        public void ShouldReturnAngleBetweenVectorsOnXYPlane()
        {
            PVector vectorA = new PVector(1, 0);
            PVector vectorB = new PVector(0, 1);

            float expectedTheta = (float)Math.PI / 2;
            float actualTheta   = vectorA.AngleBetween(vectorB);

            Assert.Equal(expectedTheta, actualTheta);


            vectorA = new PVector(2, 7);
            vectorB = new PVector(1, -4);

            float expectedThetaInDegrees = 150.01836f;
            float actualThetaInDegrees   = Helpers.ConvertionHelper.RadiansToDegrees(vectorA.AngleBetween(vectorB));

            Assert.Equal(expectedThetaInDegrees, actualThetaInDegrees);
        }
Esempio n. 31
0
        public void ShouldStaticallyCalculateCrossProductOfTwoVectorsAndSetTargetVector()
        {
            PVector aVector        = new PVector(3, 4, 5);
            PVector bVector        = new PVector(1, 2, 3);
            PVector targetVector   = new PVector(6, 7, 8);
            PVector expectedResult = new PVector(2, -4, 2);

            PVector crossProductVector = PVector.Cross(aVector, bVector, targetVector);

            Assert.NotSame(targetVector, expectedResult);

            Assert.Equal(expectedResult.X, targetVector.X);
            Assert.Equal(expectedResult.Y, targetVector.Y);
            Assert.Equal(expectedResult.Z, targetVector.Z);

            Assert.Equal(expectedResult.X, crossProductVector.X);
            Assert.Equal(expectedResult.Y, crossProductVector.Y);
            Assert.Equal(expectedResult.Z, crossProductVector.Z);
        }
Esempio n. 32
0
        static void Main(string[] args)
        {
            using (Canvas canvas = new Canvas(800, 640))
            {
                PImage squid = default(PImage);

                canvas.Setup += _ =>
                {
                    squid = PImage.FromFile("squid.jpg").Resize(256, 256);
                };

                canvas.Draw += _ =>
                {
                    canvas.WithStyle(() =>
                    {
                        canvas.Stroke = Color4.Red;
                        canvas.Fill   = Color4.Green;

                        canvas.StrokeWeight = 2;

                        PVector a = canvas.MousePosition;
                        var c     = (200, 200);

                        canvas.Rectangle(a, c);

                        canvas.Fill = Color4.DeepSkyBlue;

                        canvas.WithBoundry(a, c, () =>
                        {
                            canvas.Image(squid, (0, 0));
                        });
                    });

                    //canvas.Image(squid, (canvas.Width - squid.Width, canvas.Height - squid.Height));

                    canvas.Fill = Color4.Firebrick;
                    //canvas.Text("Hello, world!", (10, 10));
                };

                canvas.Run(60f);
            }
        }
Esempio n. 33
0
    //FLAWED
    public void roundEdges(float d)
    {
        if (d <= 0)
        {
            return;
        }

        List <Plane> cutPlanes = new List <Plane> ();
        PVector      center    = new PVector();

        for (int i = 0; i < vertices.Count; i++)
        {
            HE_Vertex v = vertices [i];
            center.add(v);
        }
        center.div(vertices.Count);

        for (int i = 0; i < edges.Count; i++)
        {
            HE_Edge   e  = edges [i];
            HE_Vertex v1 = e.halfEdge.vert;
            HE_Vertex v2 = e.halfEdge.pair.vert;
            HE_Vertex v  = new HE_Vertex(0.5f * (v1.x + v2.x), 0.5f * (v1.y + v2.y), 0.5f * (v1.z + v2.z), 0);

            PVector n = PVector.sub(v, center);
            //float distanceToVertex=n.mag();
            //if(distanceToVertex>d){
            float distanceToVertex = n.magSq();
            if (distanceToVertex > d * d)
            {
                float   ratio  = (distanceToVertex - d) / distanceToVertex;
                PVector origin = PVector.mult(n, ratio);
                origin.add(center);
                cutPlanes.Add(new Plane(origin, n));
            }
        }
        for (int i = 0; i < cutPlanes.Count; i++)
        {
            Plane P = cutPlanes [i];
            cutMesh(P, center);
        }
    }
Esempio n. 34
0
 public static PVector mult(PVector v, float n)
 {
     PVector p = new PVector ();
     p.pos = v.pos * n;
     return p;
 }
Esempio n. 35
0
        /// <summary>
        /// Draws a skeleton's bones and joints
        /// </summary>
        /// <param name="skeleton">skeleton to draw</param>
        /// <param name="drawingContext">drawing context to draw to</param>
        private void DrawBonesAndJoints(Skeleton skeleton, DrawingContext drawingContext)
        {
            Joint leftj = skeleton.Joints[JointType.HandLeft];
            Joint rightj = skeleton.Joints[JointType.HandRight];
            Joint bodyj = skeleton.Joints[JointType.ShoulderCenter];

            PVector jointPos = new PVector();
            context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_HEAD, jointPos);

            //writeText(drawingContext, string.Format("left: {0:f4}x, {0:f4}y, {0:f4}z", leftj.Position.X, leftj.Position.Y, leftj.Position.Z) +
            //     string.Format("\nright: {0:f4}x, {0:f4}y, {0:f4}z", rightj.Position.X, rightj.Position.Y, rightj.Position.Z) +
            //     string.Format("\nright: {0:f4}x, {0:f4}y, {0:f4}z", bodyj.Position.X, bodyj.Position.Y, bodyj.Position.Z));

            // Render Torso
            //this.DrawBone(skeleton, drawingContext, JointType.Head, JointType.ShoulderCenter);
            this.DrawBone(skeleton, drawingContext, JointType.ShoulderCenter, JointType.ShoulderLeft);
            this.DrawBone(skeleton, drawingContext, JointType.ShoulderCenter, JointType.ShoulderRight);
            this.DrawBone(skeleton, drawingContext, JointType.ShoulderCenter, JointType.Spine);
            this.DrawBone(skeleton, drawingContext, JointType.Spine, JointType.HipCenter);
            this.DrawBone(skeleton, drawingContext, JointType.HipCenter, JointType.HipLeft);
            this.DrawBone(skeleton, drawingContext, JointType.HipCenter, JointType.HipRight);

            // Left Arm
            this.DrawBone(skeleton, drawingContext, JointType.ShoulderLeft, JointType.ElbowLeft);
            this.DrawBone(skeleton, drawingContext, JointType.ElbowLeft, JointType.WristLeft);
            this.DrawBone(skeleton, drawingContext, JointType.WristLeft, JointType.HandLeft);

            // Right Arm
            this.DrawBone(skeleton, drawingContext, JointType.ShoulderRight, JointType.ElbowRight);
            this.DrawBone(skeleton, drawingContext, JointType.ElbowRight, JointType.WristRight);
            this.DrawBone(skeleton, drawingContext, JointType.WristRight, JointType.HandRight);

            // Left Leg
            this.DrawBone(skeleton, drawingContext, JointType.HipLeft, JointType.KneeLeft);
            this.DrawBone(skeleton, drawingContext, JointType.KneeLeft, JointType.AnkleLeft);
            this.DrawBone(skeleton, drawingContext, JointType.AnkleLeft, JointType.FootLeft);

            // Right Leg
            this.DrawBone(skeleton, drawingContext, JointType.HipRight, JointType.KneeRight);
            this.DrawBone(skeleton, drawingContext, JointType.KneeRight, JointType.AnkleRight);
            this.DrawBone(skeleton, drawingContext, JointType.AnkleRight, JointType.FootRight);

            // Render Joints
            foreach (Joint joint in skeleton.Joints)
            {
                Brush drawBrush = null;

                if (joint.TrackingState == JointTrackingState.Tracked)
                {
                    drawBrush = this.trackedJointBrush;
                }
                else if (joint.TrackingState == JointTrackingState.Inferred)
                {
                    drawBrush = this.inferredJointBrush;
                }

                if (drawBrush != null)
                {
                    drawingContext.DrawEllipse(drawBrush, null, this.SkeletonPointToScreen(joint.Position), JointThickness, JointThickness);
                }
            }
        }
Esempio n. 36
0
        /// <summary>
        /// calculate radius and circle of outer circle from tetrahedron points 
        /// ref URL http://www.openprocessing.org/sketch/31295
        /// </summary>
        private void getCenterCircumcircle()
        {
            //translation from P1
            double[,] A = new double[,] {
            {P2.X - P1.X, P2.Y-P1.Y, P2.Z-P1.Z},
            {P3.X - P1.X, P3.Y-P1.Y, P3.Z-P1.Z},
            {P4.X - P1.X, P4.Y-P1.Y, P4.Z-P1.Z}
            };
            //I did not understand this mean
            double[] b = new double[]{
            0.5 * (P2.X*P2.X - P1.X*P1.X + P2.Y*P2.Y - P1.Y*P1.Y + P2.Z*P2.Z - P1.Z*P1.Z),
            0.5 * (P3.X*P3.X - P1.X*P1.X + P3.Y*P3.Y - P1.Y*P1.Y + P3.Z*P3.Z - P1.Z*P1.Z),
            0.5 * (P4.X*P4.X - P1.X*P1.X + P4.Y*P4.Y - P1.Y*P1.Y + P4.Z*P4.Z - P1.Z*P1.Z)
            };

            //solve
            double[] x = new double[3];
            if ( gauss(A, b, x) == 0 )
            {
                O = null;
                R = -1;
            }
            else
            {
                O = new PVector((float)x[0], (float)x[1], (float)x[2]);
                R = Common.GetDist(O, P1);
            }
        }
Esempio n. 37
0
 public float dot(PVector a)
 {
     return Vector3.Dot (pos, a.pos);
 }
Esempio n. 38
0
 public static void line(PVector p0, PVector p1)
 {
     Debug.DrawLine (new Vector3 (p0.x, p0.y, p0.z), new Vector3 (p1.x, p1.y, p1.z));
 }
Esempio n. 39
0
 public static PVector sub(PVector v1, PVector v2)
 {
     PVector p = new PVector ();
     p.pos = v1.pos - v2.pos;
     return p;
 }
Esempio n. 40
0
 public void add(PVector p)
 {
     pos += p.pos;
 }
Esempio n. 41
0
 public static float dist(PVector a, PVector b)
 {
     return Vector3.Distance (a.pos, b.pos);
 }
Esempio n. 42
0
 public static PVector add(PVector v1, PVector v2)
 {
     PVector p = new PVector ();
     p.pos = v1.pos + v2.pos;
     return p;
 }
Esempio n. 43
0
 public void sub(PVector p)
 {
     pos += -p.pos;
 }
Esempio n. 44
-1
        public PVector GetNormal()
        {
            PVector edge1 = new PVector(V2.X - V1.X, V2.Y - V1.Y, V2.Z - V1.Z);
            PVector edge2 = new PVector(V3.X - V1.X, V3.Y - V1.Y, V3.Z - V1.Z);

            PVector normal = edge1.Cross(edge2);

            return normal.GetNormalization();
        }