+
This commit is contained in:
@ -106,51 +106,55 @@ namespace DroneSimulator
|
||||
|
||||
foreach (var d in DroneList)
|
||||
{
|
||||
if (d.Azimuth >= 360) d.Azimuth -= 360;
|
||||
var bmp = RotateImage(d.Drone, d.Azimuth);
|
||||
|
||||
g.FillEllipse(new SolidBrush(Color.FromArgb(50, d.RGB)), d.PosXY.X + d.Height, d.PosXY.Y + d.Height, 130, 130);
|
||||
|
||||
g.DrawLine(new Pen(Color.Black), new Point(d.PosXY.X + d.Drone.Width / 2, d.PosXY.Y + d.Drone.Height / 2), new Point(d.PosXY.X + d.Height + d.Drone.Width / 2, d.PosXY.Y + d.Height + d.Drone.Height / 2));
|
||||
|
||||
//g.DrawImage(bmp, new Rectangle(d.PosXY.X+32, d.PosXY.Y, 65, 130));
|
||||
|
||||
float x1 = 0, y1 = 0;
|
||||
float x2 = 130, y2 = 0;
|
||||
float x3 = 0, y3 = 130;
|
||||
|
||||
const float TO_RADI = MathF.PI / 180;
|
||||
|
||||
Quaternion tilt = new Quaternion(d.TiltXY.X, d.TiltXY.Y, 0, 0);
|
||||
Quaternion rotate = Quaternion.CreateFromAxisAngle(new Vector3(0, 0, 1), d.Azimuth * TO_RADI);
|
||||
|
||||
tilt = tilt * rotate * rotate;
|
||||
|
||||
if (tilt.Y > 0)
|
||||
try
|
||||
{
|
||||
x1 = (int)(Math.Sin(tilt.Y) * 130);
|
||||
x3 = (int)(Math.Sin(tilt.Y) * 130);
|
||||
}
|
||||
else
|
||||
{
|
||||
x2 = (int)(Math.Cos(tilt.Y) * 130);
|
||||
}
|
||||
if (d.Azimuth >= 360) d.Azimuth -= 360;
|
||||
var bmp = RotateImage(d.Drone, d.Azimuth);
|
||||
|
||||
if (tilt.X > 0)
|
||||
{
|
||||
y1 = (int)(Math.Sin(tilt.X) * 130);
|
||||
y2 = (int)(Math.Sin(tilt.X) * 130);
|
||||
}
|
||||
else
|
||||
{
|
||||
y3 = (int)(Math.Cos(tilt.X) * 130);
|
||||
}
|
||||
g.FillEllipse(new SolidBrush(Color.FromArgb(50, d.RGB)), d.PosXY.X + d.Height, d.PosXY.Y + d.Height, 130, 130);
|
||||
|
||||
PointF ul = new PointF(d.PosXY.X + x1, d.PosXY.Y + y1); PointF ur = new PointF(d.PosXY.X + x2, d.PosXY.Y + y2);
|
||||
PointF dl = new PointF(d.PosXY.X + x3, d.PosXY.Y + y3);
|
||||
PointF[] dest = { ul, ur, dl };
|
||||
g.DrawLine(new Pen(Color.Black), new Point(d.PosXY.X + d.Drone.Width / 2, d.PosXY.Y + d.Drone.Height / 2), new Point(d.PosXY.X + d.Height + d.Drone.Width / 2, d.PosXY.Y + d.Height + d.Drone.Height / 2));
|
||||
|
||||
g.DrawImage(bmp, dest);
|
||||
//g.DrawImage(bmp, new Rectangle(d.PosXY.X+32, d.PosXY.Y, 65, 130));
|
||||
|
||||
float x1 = 0, y1 = 0;
|
||||
float x2 = 130, y2 = 0;
|
||||
float x3 = 0, y3 = 130;
|
||||
|
||||
const float TO_RADI = MathF.PI / 180;
|
||||
|
||||
Quaternion tilt = new Quaternion(d.TiltXY.X, d.TiltXY.Y, 0, 0);
|
||||
Quaternion rotate = Quaternion.CreateFromAxisAngle(new Vector3(0, 0, 1), d.Azimuth * TO_RADI);
|
||||
|
||||
tilt = tilt * rotate * rotate;
|
||||
|
||||
if (tilt.Y > 0)
|
||||
{
|
||||
x1 = (int)(Math.Sin(tilt.Y) * 130);
|
||||
x3 = (int)(Math.Sin(tilt.Y) * 130);
|
||||
}
|
||||
else
|
||||
{
|
||||
x2 = (int)(Math.Cos(tilt.Y) * 130);
|
||||
}
|
||||
|
||||
if (tilt.X > 0)
|
||||
{
|
||||
y1 = (int)(Math.Sin(tilt.X) * 130);
|
||||
y2 = (int)(Math.Sin(tilt.X) * 130);
|
||||
}
|
||||
else
|
||||
{
|
||||
y3 = (int)(Math.Cos(tilt.X) * 130);
|
||||
}
|
||||
|
||||
PointF ul = new PointF(d.PosXY.X + x1, d.PosXY.Y + y1); PointF ur = new PointF(d.PosXY.X + x2, d.PosXY.Y + y2);
|
||||
PointF dl = new PointF(d.PosXY.X + x3, d.PosXY.Y + y3);
|
||||
PointF[] dest = { ul, ur, dl };
|
||||
|
||||
g.DrawImage(bmp, dest);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user