private void _SetPoints() { // Reduce points if needed. if (_reductionMethod != ReductionMethod.None) { if (_reductionMethod == ReductionMethod.GridPartition) { _meaningPoints = HeatMap2D.GridPartition(_points, _reducedPointsCount); Debug.Log("[HeatMap2D_Test] " + _points.Count + " points reduced to " + _meaningPoints.Count + " points using GridPartition."); } else if (_reductionMethod == ReductionMethod.CanopyClustering) { _meaningPoints = HeatMap2D.CanopyClustering(_points, _canopyClusteringMaxDistance); Debug.Log("[HeatMap2D_Test] " + _points.Count + " points reduced to " + _meaningPoints.Count + " points using CanopyClustering."); } else if (_reductionMethod == ReductionMethod.Decimation) { _meaningPoints = HeatMap2D.Decimation(_points, _reducedPointsCount); Debug.Log("[HeatMap2D_Test] " + _points.Count + " points reduced to " + _meaningPoints.Count + " points using Decimation."); } heatmap.SetPoints(_meaningPoints); } else { // Points reduction not needed. heatmap.SetPoints(_points); Debug.Log("[HeatMap2D_Test] " + _points.Count + " points rendered."); } }
private void _GeneratePoints() { // Generate points. _points.Clear(); Vector3 size = heatmap.WorldBounds.size; float scaleFactor = (float)HeatMap2D.MAX_POINTS_COUNT / (float)_pointsCount; float xLength = 0.0f, zLength = 0.0f, lengthStep = 0.0005f * scaleFactor; float angleRad = 0.0f, angleRadStep = Mathf.Deg2Rad * 0.5f; Vector4 point = new Vector4(0.0f, 0.0f, 0.0f, 1.0f); Vector3 dir = new Vector3(0.0f, 0.0f, 1.0f); while (_points.Count < _pointsCount) { // Add point. _points.Add(point); // Compute next point. angleRad += angleRadStep; xLength += lengthStep * size.x; zLength += lengthStep * size.z; dir.Set(Mathf.Cos(angleRad), 0.0f, Mathf.Sin(angleRad)); point = dir.normalized; point.x *= xLength; point.z *= zLength; point.w = 1.0f; } // Reduce points if needed. if (_points.Count > HeatMap2D.MAX_POINTS_COUNT) { // Points reduction needed. _meaningPoints = HeatMap2D.Decimation(_points, HeatMap2D.MAX_POINTS_COUNT); heatmap.SetPoints(_meaningPoints); Debug.Log("[HeatMap2D_InfiniteTrajectoryTest] " + _points.Count + " points rendered using " + _meaningPoints.Count + " meaningful points."); } else { // Points reduction not needed. heatmap.SetPoints(_points); Debug.Log("[HeatMap2D_InfiniteTrajectoryTest] " + _points.Count + " points rendered."); } }