-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriangle.cs
More file actions
48 lines (40 loc) · 1.08 KB
/
Copy pathTriangle.cs
File metadata and controls
48 lines (40 loc) · 1.08 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
using OpenTK.Mathematics;
using System;
namespace Project3D
{
public class Triangle
{
private Vector2[] _points;
public Vector2 this[int i]
{
get { return _points[i]; }
set { _points[i] = value; }
}
public float Area
{
get
{
float a = (_points[0] - _points[1]).Length;
float b = (_points[1] - _points[2]).Length;
float c = (_points[2] - _points[0]).Length;
float p = (a + b + c) / 2f;
return MathF.Sqrt(p * (p - a) * (p - b) * (p - c));
}
}
public Triangle()
{
_points = new Vector2[3];
}
public Triangle(Vector2 pointA, Vector2 pointB, Vector2 pointC)
{
_points = new Vector2[3];
_points[0] = pointA;
_points[1] = pointB;
_points[2] = pointC;
}
public override string ToString()
{
return $"{{ {_points[0]}; {_points[1]}; {_points[2]} }}";
}
}
}