mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-07 09:46:37 +08:00
block
This commit is contained in:
@@ -14,7 +14,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
List<Point> points = new List<Point>();
|
||||
points.Add(startPoint);
|
||||
|
||||
Point thisPoint= startPoint;
|
||||
Point thisPoint = startPoint;
|
||||
double thisAngle = angle;
|
||||
|
||||
Point nextPoint;
|
||||
@@ -42,7 +42,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
/// <param name="startPoint">起点</param>
|
||||
/// <param name="distance">距离</param>
|
||||
/// <returns>终点坐标</returns>
|
||||
public static Point GetEndPointByTrigonometric(Point startPoint, double angle, double distance)
|
||||
public static Point GetEndPointByTrigonometric(Point startPoint, double angle, double distance)
|
||||
{
|
||||
//角度转弧度
|
||||
var radian = (angle * Math.PI) / 180;
|
||||
@@ -62,7 +62,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
/// <returns>终点坐标</returns>
|
||||
public static Point GetEndPointByDirection(Point startPoint, double direction, double distance)
|
||||
{
|
||||
return GetEndPointByTrigonometric(startPoint, direction - 90, distance);
|
||||
return GetEndPointByTrigonometric(startPoint, 90 - direction, distance);
|
||||
}
|
||||
|
||||
public static double GetAngle(Point startPoint, Point endPoint)
|
||||
@@ -74,9 +74,18 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
public static double GetDirection(Point startPoint, Point endPoint)
|
||||
{
|
||||
var radian = (endPoint.Y - startPoint.Y) / (endPoint.X - startPoint.X);
|
||||
|
||||
var radian = Math.Atan2(endPoint.Y - startPoint.Y, endPoint.X - startPoint.X);
|
||||
var angle = radian * 180 / Math.PI;
|
||||
return angle + 90;
|
||||
if (angle >= -90 && angle < 90)
|
||||
{
|
||||
return 90 - angle;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return angle - 90;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user