ProjectorPInfo.cs
3.0 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TSA_V.DeviceLibrary
{
public class ProjectorPInfo
{
public ProjectorPInfo(double x, double y, int type=1,int polaritiesType=0, int angle=0,int sizeX=4, int sizeY=4,int lineWidth=2,string showText="",int color=-1)
{
this.PX = x;
this.PY = y;
this.PType = type;
this.SizeX = sizeX;
this.SizeY = sizeY;
this.PenWidth = lineWidth;
this.ShowText = showText;
this.showColor = color;
this.PolaritiesType= polaritiesType;
this.PolarityAngle = angle;
}
public double PX = 2;
public double PY = 2;
public int PType = 1;
public int SizeX = 4;
public int SizeY = 4;
/// <summary>
/// 线条宽度
/// </summary>
public int PenWidth = 2;
public string ShowText = "";
public int showColor = -1;
/// <summary>
/// 极性,
/// </summary>
public int PolaritiesType = 0;
/// <summary>
/// 极性角度,
/// </summary>
public int PolarityAngle { get; set; } = 0;
public static int getAngleByType(int type, int angle)
{
int ret = 0;
switch (type)
{
case 0:
break;
case 1:
ret = 270;
break;
case 2:
ret = 90;
break;
case 3:
ret = 180;
break;
case 4:
ret = 0;
break;
case 5:
ret = 225;
break;
case 6:
ret = 315;
break;
case 7:
ret = 135;
break;
case 8:
ret = 45;
break;
case 9:
ret = angle;
break;
}
return ret;
}
/// <summary>
/// 计算极性的中心位置
/// </summary>
/// <param name="point">点位中心</param>
/// <param name="distance">距离</param>
/// <param name="angleInDegrees">角度</param>
/// <returns></returns>
public static Point CalculatePoint(Point point, double distance, double angleInDegrees)
{
double angleInRadians = angleInDegrees * (Math.PI / 180.0);
double deltaX = distance * Math.Cos(angleInRadians);
double deltaY = distance * Math.Sin(angleInRadians);
int newX = (int)(point.X + deltaX);
int newY = (int)(point.Y + deltaY);
return new Point(newX, newY);
}
}
}