mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-05-04 23:10:25 +08:00
block
This commit is contained in:
@@ -14,7 +14,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
List<Point> points = new List<Point>();
|
List<Point> points = new List<Point>();
|
||||||
points.Add(startPoint);
|
points.Add(startPoint);
|
||||||
|
|
||||||
Point thisPoint= startPoint;
|
Point thisPoint = startPoint;
|
||||||
double thisAngle = angle;
|
double thisAngle = angle;
|
||||||
|
|
||||||
Point nextPoint;
|
Point nextPoint;
|
||||||
@@ -42,7 +42,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
/// <param name="startPoint">起点</param>
|
/// <param name="startPoint">起点</param>
|
||||||
/// <param name="distance">距离</param>
|
/// <param name="distance">距离</param>
|
||||||
/// <returns>终点坐标</returns>
|
/// <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;
|
var radian = (angle * Math.PI) / 180;
|
||||||
@@ -62,7 +62,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
/// <returns>终点坐标</returns>
|
/// <returns>终点坐标</returns>
|
||||||
public static Point GetEndPointByDirection(Point startPoint, double direction, double distance)
|
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)
|
public static double GetAngle(Point startPoint, Point endPoint)
|
||||||
@@ -74,9 +74,18 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
public static double GetDirection(Point startPoint, Point endPoint)
|
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;
|
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