개정판 e753423e
Create a regular triangle with given two points
KCOM/Views/MainMenu.xaml.cs | ||
---|---|---|
1658 | 1658 |
|
1659 | 1659 |
if (ViewerDataModel.Instance.IsPressShift) |
1660 | 1660 |
{ |
1661 |
Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint); |
|
1662 |
|
|
1663 |
control.MidPoint = new Point(setpoint.X - (setpoint.X - control.StartPoint.X) * 2, setpoint.Y); |
|
1664 |
control.EndPoint = setpoint; |
|
1661 |
List<Point> Points = GetRegularTrianglePoints(control.StartPoint, control.EndPoint); |
|
1662 |
if (2 == Points.Count()) |
|
1663 |
{ |
|
1664 |
control.MidPoint = Points[0]; |
|
1665 |
control.EndPoint = Points[1]; |
|
1666 |
} |
|
1665 | 1667 |
} |
1666 | 1668 |
|
1667 | 1669 |
control.PointSet = new List<Point> |
... | ... | |
5350 | 5352 |
|
5351 | 5353 |
return Return_Point; |
5352 | 5354 |
} |
5355 |
|
|
5356 |
/// <summary> |
|
5357 |
/// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌 |
|
5358 |
/// </summary> |
|
5359 |
/// <author>humkyung</author> |
|
5360 |
/// <date>2018.04.26</date> |
|
5361 |
/// <param name="StartP"></param> |
|
5362 |
/// <param name="EndP"></param> |
|
5363 |
/// <returns></returns> |
|
5364 |
private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP) |
|
5365 |
{ |
|
5366 |
List<Point> res = new List<Point>(); |
|
5367 |
|
|
5368 |
double dx = EndP.X - StartP.X; |
|
5369 |
double dy = EndP.Y - StartP.Y; |
|
5370 |
double length = Math.Sqrt(dx * dx + dy * dy); |
|
5371 |
double baseLength = length * Math.Tan(30.0* Math.PI / 180.0); |
|
5372 |
dx /= length; |
|
5373 |
dy /= length; |
|
5374 |
double tmp = dx; |
|
5375 |
dx = -dy; dy = tmp; /// rotate by 90 degree |
|
5376 |
|
|
5377 |
res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength)); |
|
5378 |
res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength)); |
|
5379 |
|
|
5380 |
return res; |
|
5381 |
} |
|
5353 | 5382 |
} |
5354 | 5383 |
} |
내보내기 Unified diff