Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit ea46683a authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

corrected naming: delauney -> Delaunay

parent a352c29b
No related branches found
No related tags found
No related merge requests found
......@@ -55,7 +55,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
[Required, Range(double.Epsilon, 1)]
public double EfficiencyToEngine { get; set; }
[Required] private readonly DelauneyMap _map;
[Required] private readonly DelaunayMap _map;
public Watt GetPowerDemand(PerSecond nAuxiliary, Watt powerAuxOut)
{
......@@ -92,7 +92,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
}
}
private static void FillFromColumnIndizes(DataTable table, DelauneyMap map)
private static void FillFromColumnIndizes(DataTable table, DelaunayMap map)
{
var data = table.Rows.Cast<DataRow>().Select(row => new {
AuxiliarySpeed = row.ParseDouble(0).RPMtoRad(),
......@@ -104,7 +104,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
}
}
private static void FillFromColumnNames(DataTable table, DelauneyMap map)
private static void FillFromColumnNames(DataTable table, DelaunayMap map)
{
var data = table.Rows.Cast<DataRow>().Select(row => new {
AuxiliarySpeed = row.ParseDouble(Fields.AuxSpeed).RPMtoRad(),
......@@ -118,12 +118,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
internal AuxiliaryData(string id)
{
_map = new DelauneyMap(id);
_map = new DelaunayMap(id);
}
internal AuxiliaryData(IAuxiliaryEngineeringInputData data, string id)
{
_map = new DelauneyMap("AuxiliaryData " + id);
_map = new DelaunayMap("AuxiliaryData " + id);
TransmissionRatio = data.TransmissionRatio;
EfficiencyToEngine = data.EfficiencyToEngine;
EfficiencyToSupply = data.EfficiencyToSupply;
......
......@@ -42,7 +42,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine
{
public class FuelConsumptionMap : SimulationComponentData
{
[Required, ValidateObject] private readonly DelauneyMap _fuelMap = new DelauneyMap("FuelConsumptionMap");
[Required, ValidateObject] private readonly DelaunayMap _fuelMap = new DelaunayMap("FuelConsumptionMap");
private FuelConsumptionMap() {}
......@@ -77,7 +77,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine
try {
var entry = headerValid ? CreateFromColumNames(row) : CreateFromColumnIndizes(row);
// Delauney map works only as expected, when the angularVelocity is in rpm.
// Delaunay map works only as expected, when the angularVelocity is in rpm.
fuelConsumptionMap._fuelMap.AddPoint(entry.Torque.Value(),
headerValid ? row.ParseDouble(Fields.EngineSpeed) : row.ParseDouble(0),
entry.FuelConsumption.Value());
......@@ -125,7 +125,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine
public KilogramPerSecond GetFuelConsumption(NewtonMeter torque, PerSecond angularVelocity,
bool allowExtrapolation = false)
{
// delauney map needs is initialised with rpm, therefore the angularVelocity has to be converted.
// delaunay map needs is initialised with rpm, therefore the angularVelocity has to be converted.
return
_fuelMap.Interpolate(torque.Value(), angularVelocity.ConvertTo().Rounds.Per.Minute.Value(), allowExtrapolation)
.SI().Kilo.Gramm.Per.Second.Cast<KilogramPerSecond>();
......
......@@ -52,12 +52,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox
/// <summary>
/// The Loss map. [X=Output EngineSpeed, Y=Output Torque] => Z=Torque Loss
/// </summary>
private readonly DelauneyMap _lossMap;
private readonly DelaunayMap _lossMap;
/// <summary>
/// The inverted loss map for range sanity checks. [X=Input EngineSpeed, Y=Input Torque] => Z=Output Torque
/// </summary>
private readonly DelauneyMap _invertedLossMap;
private readonly DelaunayMap _invertedLossMap;
/// <summary>
/// True if the last access to GetInTorque was an extrapolation.
......@@ -144,8 +144,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox
GearName = gearName;
_ratio = gearRatio;
_entries = entries;
_lossMap = new DelauneyMap("TransmissionLossMap " + GearName);
_invertedLossMap = new DelauneyMap("TransmissionLossMapInv. " + GearName);
_lossMap = new DelaunayMap("TransmissionLossMap " + GearName);
_invertedLossMap = new DelaunayMap("TransmissionLossMapInv. " + GearName);
foreach (var entry in _entries) {
_lossMap.AddPoint(entry.InputSpeed.ConvertTo().Rounds.Per.Minute.Value(),
(entry.InputTorque - entry.TorqueLoss).Value(), entry.TorqueLoss.Value());
......
......@@ -45,7 +45,7 @@ using TUGraz.VectoCommon.Utils;
namespace TUGraz.VectoCore.Utils
{
[JsonObject(MemberSerialization.Fields)]
public class DelauneyMap : LoggingObject
public class DelaunayMap : LoggingObject
{
internal readonly ICollection<Point> Points = new HashSet<Point>();
private List<Triangle> _triangles = new List<Triangle>();
......@@ -55,7 +55,7 @@ namespace TUGraz.VectoCore.Utils
private readonly string _mapName;
public DelauneyMap(string name)
public DelaunayMap(string name)
{
_mapName = name;
}
......@@ -122,18 +122,18 @@ namespace TUGraz.VectoCore.Utils
triangles.AddRange(newTriangles);
//DrawGraph(pointCount, triangles, superTriangle, xmin, xmax, ymin, ymax, point);
pointCount++;
// check invariant: m = 2n-2-k
// m...triangle count
// n...point count (pointCount +3 points on the supertriangle)
// k...points on convex hull (exactly 3 --> supertriangle)
if (triangles.Count != 2 * (pointCount + 3) - 2 - 3) {
throw new VectoException(
"Delauney-Triangulation invariant violated! Triangle count and point count doesn't fit together.");
"Delaunay-Triangulation invariant violated! Triangle count and point count doesn't fit together.");
}
}
//DrawGraph(pointCount, triangles, superTriangle, xmin, xmax, ymin, ymax);
DrawGraph(pointCount, triangles, superTriangle, xmin, xmax, ymin, ymax);
_convexHull = triangles.FindAll(t => t.SharesVertexWith(superTriangle)).
SelectMany(t => t.GetEdges()).
......@@ -150,28 +150,33 @@ namespace TUGraz.VectoCore.Utils
Log.Error("{0}: Input Point appears twice: x: {1}, y: {2}", duplicate.Key.X, duplicate.Key.Y);
}
if (duplicates.Any()) {
throw new VectoException("{0}: Input Data for Delauney map contains duplicates! \n{1}", _mapName,
throw new VectoException("{0}: Input Data for Delaunay map contains duplicates! \n{1}", _mapName,
string.Join("\n", duplicates.Select(pt => string.Format("{0} / {1}", pt.Key.X, pt.Key.Y))));
}
}
/// <summary>
/// Draws the delauney map (except supertriangle).
/// Draws the delaunay map (except supertriangle).
/// </summary>
private void DrawGraph(int i, List<Triangle> triangles, Triangle superTriangle, double xmin, double xmax, double ymin, double ymax, Point lastPoint = null)
private void DrawGraph(int i, List<Triangle> triangles, Triangle superTriangle, double xmin, double xmax, double ymin,
double ymax, Point lastPoint = null)
{
using (var chart = new Chart { Width = 1000, Height = 1000 }) {
chart.ChartAreas.Add(new ChartArea("main") {
AxisX = new Axis { Minimum = Math.Min(xmin, ymin), Maximum = Math.Max(xmax,ymax) },
AxisY = new Axis { Minimum = Math.Min(xmin, ymin), Maximum = Math.Max(xmax,ymax) }
AxisX = new Axis { Minimum = Math.Min(xmin, xmin), Maximum = Math.Max(xmax, xmax) },
AxisY = new Axis { Minimum = Math.Min(ymin, ymin), Maximum = Math.Max(ymax, ymax) }
});
foreach (var tr in triangles) {
if (tr.SharesVertexWith(superTriangle))
if (tr.SharesVertexWith(superTriangle)) {
continue;
}
var series = new Series { ChartType = SeriesChartType.FastLine, Color = lastPoint != null && tr.Contains(lastPoint)? Color.Red : Color.Blue };
var series = new Series {
ChartType = SeriesChartType.FastLine,
Color = lastPoint != null && tr.Contains(lastPoint) ? Color.Red : Color.Blue
};
series.Points.AddXY(tr.P1.X, tr.P1.Y);
series.Points.AddXY(tr.P2.X, tr.P2.Y);
series.Points.AddXY(tr.P3.X, tr.P3.Y);
......@@ -180,7 +185,12 @@ namespace TUGraz.VectoCore.Utils
}
if (lastPoint != null) {
var series = new Series{ ChartType = SeriesChartType.Point, Color = Color.Red, MarkerSize = 5, MarkerStyle = MarkerStyle.Circle};
var series = new Series {
ChartType = SeriesChartType.Point,
Color = Color.Red,
MarkerSize = 5,
MarkerStyle = MarkerStyle.Circle
};
series.Points.AddXY(lastPoint.X, lastPoint.Y);
chart.Series.Add(series);
}
......@@ -189,8 +199,8 @@ namespace TUGraz.VectoCore.Utils
var method = frame.GetMethod();
var type = string.Join("", method.DeclaringType.Name.Split(Path.GetInvalidFileNameChars()));
var methodName = string.Join("", method.Name.Split(Path.GetInvalidFileNameChars()));
Directory.CreateDirectory("delauney");
chart.SaveImage(string.Format("delauney\\{0}_{1}_{2}_{3}.png", type, methodName, superTriangle.GetHashCode(), i),
Directory.CreateDirectory("delaunay");
chart.SaveImage(string.Format("delaunay\\{0}_{1}_{2}_{3}.png", type, methodName, superTriangle.GetHashCode(), i),
ChartImageFormat.Png);
}
}
......@@ -270,7 +280,7 @@ namespace TUGraz.VectoCore.Utils
#region Equality members
protected bool Equals(DelauneyMap other)
protected bool Equals(DelaunayMap other)
{
return Points.SequenceEqual(other.Points) && _triangles.SequenceEqual(other._triangles);
}
......@@ -286,7 +296,7 @@ namespace TUGraz.VectoCore.Utils
if (obj.GetType() != GetType()) {
return false;
}
return Equals((DelauneyMap)obj);
return Equals((DelaunayMap)obj);
}
public override int GetHashCode()
......
......@@ -262,7 +262,7 @@
<Compile Include="Utils\Validation.cs" />
<Compile Include="Utils\VectoCSVFile.cs" />
<Compile Include="Utils\VectoMath.cs" />
<Compile Include="Utils\DelauneyMap.cs" />
<Compile Include="Utils\DelaunayMap.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
......
......@@ -37,12 +37,12 @@ using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Tests.Utils
{
[TestClass]
public class DelauneyMapTest
public class DelaunayMapTest
{
[TestMethod]
public void Test_Simple_DelauneyMap()
public void Test_Simple_DelaunayMap()
{
var map = new DelauneyMap("TEST");
var map = new DelaunayMap("TEST");
map.AddPoint(0, 0, 0);
map.AddPoint(1, 0, 0);
map.AddPoint(0, 1, 0);
......@@ -55,9 +55,9 @@ namespace TUGraz.VectoCore.Tests.Utils
}
[TestMethod]
public void Test_DelauneyMapTriangle()
public void Test_DelaunayMapTriangle()
{
var map = new DelauneyMap("TEST");
var map = new DelaunayMap("TEST");
map.AddPoint(0, 0, 0);
map.AddPoint(1, 0, 1);
map.AddPoint(0, 1, 2);
......@@ -88,9 +88,9 @@ namespace TUGraz.VectoCore.Tests.Utils
AssertHelper.Exception<VectoException>(() => map.Interpolate(-1, 1), "TEST: Interpolation failed. x: -1, y: 1");
}
public void Test_DelauneyMapPlane()
public void Test_DelaunayMapPlane()
{
var map = new DelauneyMap("TEST");
var map = new DelaunayMap("TEST");
map.AddPoint(0, 0, 0);
map.AddPoint(1, 0, 1);
map.AddPoint(0, 1, 2);
......@@ -130,25 +130,25 @@ namespace TUGraz.VectoCore.Tests.Utils
}
[TestMethod]
public void Test_Delauney_LessThan3Points()
public void Test_Delaunay_LessThan3Points()
{
AssertHelper.Exception<ArgumentException>(() => new DelauneyMap("TEST").Triangulate(),
AssertHelper.Exception<ArgumentException>(() => new DelaunayMap("TEST").Triangulate(),
"TEST: Triangulation needs at least 3 Points. Got 0 Points.");
AssertHelper.Exception<ArgumentException>(() => {
var map1 = new DelauneyMap("TEST");
var map1 = new DelaunayMap("TEST");
map1.AddPoint(1, 0, 0);
map1.Triangulate();
}, "TEST: Triangulation needs at least 3 Points. Got 1 Points.");
AssertHelper.Exception<ArgumentException>(() => {
var map2 = new DelauneyMap("TEST");
var map2 = new DelaunayMap("TEST");
map2.AddPoint(1, 0, 0);
map2.AddPoint(0, 1, 0);
map2.Triangulate();
}, "TEST: Triangulation needs at least 3 Points. Got 2 Points.");
var map = new DelauneyMap("TEST");
var map = new DelaunayMap("TEST");
map.AddPoint(1, 0, 0);
map.AddPoint(0, 1, 0);
map.AddPoint(0, 0, 1);
......@@ -156,9 +156,9 @@ namespace TUGraz.VectoCore.Tests.Utils
}
[TestMethod]
public void Test_Delauney_DuplicatePoints()
public void Test_Delaunay_DuplicatePoints()
{
var map = new DelauneyMap("TEST");
var map = new DelaunayMap("TEST");
map.AddPoint(0, 0, 0);
map.AddPoint(1, 0, 1);
map.AddPoint(1, 1, 3);
......@@ -167,7 +167,7 @@ namespace TUGraz.VectoCore.Tests.Utils
AssertHelper.Exception<VectoException>(() => { map.Triangulate(); },
"TEST: Input Data for Delauney map contains duplicates! \n1 / 1");
"TEST: Input Data for Delaunay map contains duplicates! \n1 / 1");
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment