Added Bresenham line algorithm for one octant
This commit is contained in:
parent
710d17ff4c
commit
4b1e5b8a2b
3 changed files with 68 additions and 0 deletions
31
Assets/Scripts/Tests/BresenhamTest.cs
Normal file
31
Assets/Scripts/Tests/BresenhamTest.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Unity.Mathematics;
|
||||
|
||||
|
||||
|
||||
class BresenhamTest
|
||||
{
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public void ShapeTest()
|
||||
{
|
||||
Shape shape = new Shape(14, 6);
|
||||
Console.WriteLine("test");
|
||||
shape.SetLine(new float2(0.6f, 0.6f), new float2(10.6f, 4.6f));
|
||||
|
||||
var coords = new[] { (1, 1), (2, 1), (3, 2), (4, 2), (5, 3), (6, 3), (7, 3), (8, 4), (9, 4), (10, 5), (11, 5)};
|
||||
foreach(var coord in coords)
|
||||
{
|
||||
Assert.True(shape.Cells[coord.Item1, coord.Item2], $"{coord.Item1}, {coord.Item2}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
11
Assets/Scripts/Tests/BresenhamTest.cs.meta
Normal file
11
Assets/Scripts/Tests/BresenhamTest.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 108b8cc35b87da84c8671ee8f9386799
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in a new issue