-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndicator.cs
67 lines (60 loc) · 1.57 KB
/
Indicator.cs
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;
namespace Bulkes
{
class Indicator
{
private float x;
private float y;
private float alpha;//radians
public void getParameters(float x0, float y0, float R, float x1, float y1)
{
float k;
if (Math.Abs(x1 - x0) < 0.001f)
{
x = x0;
if (y1 < y0)
{
y = -R + y0;
alpha = (float)-Math.PI / 2.0f;// -Pi/2
}
else
{
y = R + y0;
alpha = (float)Math.PI / 2.0f;// Pi/2
}
}
else
{
k = (y1 - y0) / (x1 - x0);
if (x1 - x0 < 0)
x = (float)Math.Sqrt(1.0f / (1f + k * k)) * (-R) + x0;
else
x = (float)Math.Sqrt(1.0f / (1f + k * k)) * R + x0;
y = k * x - k * x0 + y0;
if (y1 - y0 < 0)
alpha = -(float)Math.Acos((x - x0) / R);
else
alpha = (float)Math.Acos((x - x0) / R);
}
}
public float getAlpha()
{
return alpha;
}
public float getX()
{
return x;
}
public float getY()
{
return y;
}
}
}