Example #1
0
    void RemoveSmallSegments()
    {
        var newVertices      = new NativeList <float3>(Allocator.Temp);
        var newAdjacentCells = new NativeList <WorleyNoise.CellDataX2>(Allocator.Temp);

        bool smallSegmentFound = false;

        for (int i = 0; i < cell.vertices.Length; i++)
        {
            float3 currentVertex = cell.GetVertex(i);
            float3 nextVertex    = cell.GetVertex(i + 1);

            float segmentAngle = vectorUtil.Angle(currentVertex, nextVertex);

            if (segmentAngle > minSegmentAngle)
            {
                newVertices.Add(currentVertex);
                newAdjacentCells.Add(cell.adjacentCells[i]);
            }
            else if (!smallSegmentFound)
            {
                smallSegmentFound = true;
            }
        }

        if (smallSegmentFound)
        {
            cell.vertices      = new NineValues <float3>(newVertices);
            cell.adjacentCells = new NineValues <WorleyNoise.CellDataX2>(newAdjacentCells);
        }
    }
Example #2
0
        public void SingleAngle()
        {
            Vector v1    = new Vector(0, 1);
            double angle = VectorUtil.Angle(v1);

            Assert.AreEqual(90, AngleUtil.ToDegrees(angle));
        }
Example #3
0
        public void Angle()
        {
            Vector v1    = new Vector(0, 1);
            Vector v2    = new Vector(1, -1);
            double angle = VectorUtil.Angle(v1, v2);

            Assert.AreEqual(135, AngleUtil.ToDegrees(angle));
        }