Skip to content

Commit d213e2a

Browse files
committed
refactoring, tests
1 parent 7bea139 commit d213e2a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+107908
-78
lines changed

.nuget/packages.config

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="NUnit3TestAdapter" version="3.6.0" />
4+
</packages>

Component1.Designer.cs

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Component1.cs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Diagnostics;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace WpfApplication4
10+
{
11+
public partial class Component1 : Component
12+
{
13+
public Component1()
14+
{
15+
InitializeComponent();
16+
}
17+
18+
public Component1(IContainer container)
19+
{
20+
container.Add(this);
21+
22+
InitializeComponent();
23+
}
24+
}
25+
}

Geometry/Elements/Line2d.cs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace WpfApplication4.Geometry.Elements
8+
{
9+
public class Line2d
10+
{
11+
/// <summary>
12+
/// Position Vector of line.
13+
/// </summary>
14+
/// <value>Position Vector</value>
15+
public Vector2d A { get; set; }
16+
17+
/// <summary>
18+
/// Direction Vector of the line.
19+
/// B - A
20+
/// </summary>
21+
/// <value>The direction.</value>
22+
public Vector2d R { get; set; }
23+
24+
public Line2d(Vector2d position, Vector2d direction)
25+
{
26+
A = position;
27+
R = direction;
28+
}
29+
}
30+
}

Geometry/Elements/Polygon2d.cs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Linq;
3+
using System.Text;
4+
using System.Collections.Generic;
5+
6+
namespace WpfApplication4.Geometry.Elements
7+
{
8+
public class Polygon2d
9+
{
10+
public List<Vector2d> Points { get; set; }
11+
12+
public Polygon2d ()
13+
{
14+
Points = new List<Vector2d>();
15+
}
16+
17+
public override string ToString()
18+
{
19+
StringBuilder sb = new StringBuilder();
20+
21+
foreach (var item in Points)
22+
{
23+
sb.Append(item.ToString());
24+
}
25+
26+
return sb.ToString();
27+
}
28+
}
29+
}

Geometry/Elements/Rectangle2d.cs

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace WpfApplication4.Geometry.Elements
8+
{
9+
public class Rectangle2d
10+
{
11+
public Vector2d Location { get; set; }
12+
13+
public Vector2d Size { get; set; }
14+
15+
public Rectangle2d()
16+
{
17+
}
18+
19+
public Rectangle2d(Vector2d a, Vector2d c)
20+
: this()
21+
{
22+
Location = a;
23+
Size = c - a;
24+
}
25+
26+
public double Area()
27+
{
28+
return Size.X * Size.Y;
29+
}
30+
31+
public Vector2d[] Points
32+
{
33+
get
34+
{
35+
return new[] {
36+
new Vector2d (Location.X, Location.Y),
37+
new Vector2d (Location.X + Size.X, Location.Y),
38+
new Vector2d (Location.X + Size.X, Location.Y + Size.Y),
39+
new Vector2d (Location.X, Location.Y + Size.Y)
40+
};
41+
}
42+
}
43+
}
44+
}

Geometry/Elements/Segment2d.cs

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace WpfApplication4.Geometry.Elements
8+
{
9+
public class Segment2d : Line2d
10+
{
11+
/// <summary>
12+
/// Second Point of Line.
13+
/// </summary>
14+
/// <value>The b.</value>
15+
public Vector2d B { get; set; }
16+
17+
public Segment2d(Vector2d point1, Vector2d point2) :
18+
base(point1, point2 - point1)
19+
{
20+
B = point2;
21+
}
22+
23+
public double Length()
24+
{
25+
return Math.Abs(A.Distance(B));
26+
}
27+
28+
public override string ToString()
29+
{
30+
return string.Format("[Segment2d: A={0} B={1}]", A, B);
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)