Example #1
0
    // Get the data between two dimensions (excludes the current state, includes the next one)
    public void GetTransitionalData(State prev, State next, int nbOfFramesH)
    {
        // First and last points
        PointsScatter firstPoints = pointsValues;
        PointsScatter lastPoints  = createPointsFrom(next);

        // Normalize the first or last points depending on the resolutions
        preparePoints(ref firstPoints, prev, ref lastPoints, next);

        // Transitional points
        transitionalPointsValues = new PointsScatter[nbOfFramesH];

        // Get the steps for the position and magnitude of each point
        int idx = 0;

        decimal[,] posSteps = new decimal[firstPoints.nbPoints(), 2];
        float[] magnSteps = new float[firstPoints.nbPoints()];
        Assert.AreEqual(firstPoints.nbPoints(), lastPoints.nbPoints(), "/!\\ Fatal: Dimension doesn't match.");
        foreach (KeyValuePair <Coordinate, float> p in firstPoints.points)
        {
            posSteps [idx, 0] = (lastPoints.points.Keys.ElementAt(idx)[0] - p.Key[0]) / nbOfFramesH;
            posSteps [idx, 1] = (lastPoints.points.Keys.ElementAt(idx)[1] - p.Key[1]) / nbOfFramesH;
            magnSteps[idx]    = (lastPoints.points.Values.ElementAt(idx) - p.Value) / (float)nbOfFramesH;
            idx++;
        }

        for (int f = 0; f < nbOfFramesH - 1; f++)
        {
            PointsScatter nextPoints = new PointsScatter();

            idx = 0;
            foreach (KeyValuePair <Coordinate, float> p in firstPoints.points)
            {
                nextPoints.points.Add(new Coordinate(p.Key[0] + posSteps[idx, 0], p.Key[1] + posSteps[idx, 1]),
                                      p.Value + magnSteps[idx]);
                idx++;
            }
            firstPoints = nextPoints;
            transitionalPointsValues [f] = nextPoints;
        }
    }
Example #2
0
    // Update the values of the graph to fit with the data
    public void DrawPoints(PointsScatter values)
    {
        points = new ParticleSystem.Particle[values.nbPoints()];
        int idx = 0;

        foreach (KeyValuePair <Coordinate, float> p in values.points)
        {
            points [idx].position = new Vector3((float)p.Key[0], p.Value, (float)p.Key[1]);
            float h = ColorConverter.getPercentage(p.Value, dataHandler.minMagnitude, dataHandler.maxMagnitude);
            points[idx].startColor = ColorConverter.HSVToRGB(h, 0.5f, 0.5f);
            points[idx].startSize  = 0.1f;
            idx++;
        }
        graph.GetComponent <ParticleSystem> ().SetParticles(points, points.Length);

        pointsValues = values;
    }