-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGroup.cs
More file actions
80 lines (67 loc) · 2.42 KB
/
Group.cs
File metadata and controls
80 lines (67 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace EasingPathPositionCalculator;
// 起点、终点、beat、BPM、采集密度
public class Group
{
private List<Point> _points = [];
public IReadOnlyList<Point> Points => _points.AsReadOnly();
public int Count => _points.Count;
public string GroupName { get; set; } = "unnamed";
public static short GroupSum = 0;
public short GroupUID;
public double StartX { get; set; }
public double EndX { get; set; }
public double Duration { get; set; }
public EasingType Easing { get; set; }
public int Density { get; set; }
public Group(string GroupName = "unnamed")
{
this.GroupName = GroupName;
GroupSum++;
GroupUID = GroupSum;
}
public IEnumerable<string> Traverse()
{
foreach (var point in _points)
yield return point.ToString();
}
public void CalcPoints()
{
_points.Clear();
double totalChangeX = EndX - StartX;
Log.Debug($"调试: StartX={StartX}, EndX={EndX}, totalChangeX={totalChangeX}");
Log.Debug($"调试: Duration={Duration}, Density={Density}");
for (int i = 0; i <= Duration * Density; i++)
{
double currentY = i / (double)Density;
if (currentY > Duration) break;
double currentX = EasingCalc.CalculateEasing(
Easing,
currentY,
StartX,
totalChangeX,
Duration
);
Log.Debug($"调试: i={i}, currentY={currentY}, currentX={currentX}");
// 计算整数拍数和分数部分
int beatNumber = (int)Math.Floor(currentY); // 整数拍数
int subBeatIndex = i % Density; // 在当前拍内的索引
_points.Add(new Point(currentX, beatNumber, (subBeatIndex, Density)));
}
Log.Debug($"调试: 总共生成 {_points.Count} 个点");
// 添加调试输出查看所有点
Log.Debug("所有点的详细信息:");
for (int i = 0; i < _points.Count; i++)
{
var point = _points[i];
Log.Debug($"点 {i}: {point}");
}
}
public override string ToString()
=> $"({GroupUID}){GroupName} X[{StartX} ~ {EndX}] 长度:{Duration} 密度:{Density} {Easing}({(int)Easing})";
}