34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
|
|
namespace MultiWheelC.TrajectoryPlanning.EMPlanner;
|
|
|
|
public sealed class EmTrajectory
|
|
{
|
|
public EmTrajectory(EmTrajectoryMetadata metadata, IReadOnlyList<EmTrajectoryPoint> points)
|
|
{
|
|
if (metadata == null)
|
|
throw new ArgumentNullException(nameof(metadata));
|
|
if (points == null)
|
|
throw new ArgumentNullException(nameof(points));
|
|
if (points.Count == 0)
|
|
throw new ArgumentException("A published trajectory requires at least one point.", nameof(points));
|
|
|
|
var copy = new List<EmTrajectoryPoint>(points.Count);
|
|
for (int index = 0; index < points.Count; index++)
|
|
{
|
|
if (points[index] == null)
|
|
throw new ArgumentException("Trajectory points cannot contain null values.", nameof(points));
|
|
copy.Add(points[index]);
|
|
}
|
|
|
|
Metadata = metadata;
|
|
Points = new ReadOnlyCollection<EmTrajectoryPoint>(copy);
|
|
}
|
|
|
|
public EmTrajectoryMetadata Metadata { get; }
|
|
|
|
public IReadOnlyList<EmTrajectoryPoint> Points { get; }
|
|
}
|