russell84 发表于 2022-7-6 15:44:17

导数给出切线的斜率。
 
使用atan2获取与其相切的弧。
 
此外,我必须在正象限中使用度=180角,因为我得到的答案是175和115,而它应该是5和65等等
 
谢谢你们的帮助。
 
这很有效

Lee Mac 发表于 2022-7-6 15:47:32

好的,很高兴它对你有用Russell-只是提供其他建议
 

russell84 发表于 2022-7-6 15:52:00

对于感兴趣的人来说,还有更多的角度。
 

'If you want the the angle between the line defined by these two points and the horizontal axis:
Public Function DoubleAngle (ByVal Point1 As AcadNetGeometry.Point3d, ByVal Point2 As AcadNetGeometry.Point3d) As Double
DoubleAngle = math.Atan2(Point2(1) - Point1(1),Point2(0) - Point1(0)) 'Answer in Radians
End Function


'If you want the angle bewteen the vectors OP1 and OP2 (O being the origin), you should know that the dot product between two vectors u and v is:
'u . v = u.x * v.x + u.y * v.y = |u|*|v|*cos(a)
'a being the angle between the vectors.
'So the angle is given by:
'double n1 = sqrt(x1*x1+y1*y1), n2 = sqrt(x2*x2+y2*y2);
'double angle = acos((x1*x2+y1*y2)/(n1*n2));
Public Function AngleBetweenVectors(ByVal Point1 As AcadNetGeometry.Point3d, ByVal Point2 As AcadNetGeometry.Point3d) As Double
Dim N1 As Double
N1 = Math.Sqrt(Math.Pow(Point1(0), 2) + Math.Pow(Point1(1), 2))
Dim N2 As Double
N2 = Math.Sqrt(Math.Pow(Point2(0), 2) + Math.Pow(Point2(1), 2))
Dim AngleTemp As Double = Math.Acos((Point1(0) * Point2(0) + Point1(1) * Point2(1)) / (N1 * N2)) '(in radians) * 180/MATH.PI to get degrees
AngleBetweenVectors = AngleTemp
End Function

'To get the Tangent vector to a curve at a given point (StartPt1) example
Dim VectorTangent1 As AcadNetGeometry.Vector3d = TopCurve.GetFirstDerivative(StartPt1)
'To get the Normal vector (Perp) to the vectorTangent
Dim VectorNormal1 as AcadNetGeometry.Vector3d = New AcadNetGeometry.Vector3d(-VectorTangent1.Y, VectorTangent1.X, VectorTangent1.Z)





 
如果有任何补充或建议,请张贴。
谢谢

SEANT 发表于 2022-7-6 15:56:45

都是好东西。
 
关于本规范的一项建议:
 
'To get the Normal vector (Perp) to the vectorTangent
Dim VectorNormal1 as AcadNetGeometry.Vector3d = New AcadNetGeometry.Vector3d(-VectorTangent1.Y, VectorTangent1.X, VectorTangent1.Z)
 
我知道你之前提到的重点主要是2d,但对于3d,某些情况可能会返回不理想的结果。其中最明显的情况是切线向量与世界Z对齐,即0,0,1。返回值也将为0,0,1
 
一般来说,我认为这种查询最有用的返回是垂直于切向量的向量,但也与“TopCurve”位于同一平面上(如果TopCurve确实是平面曲线)。满足这种细化的一个好方法是获得顶曲线的叉积。法线和向量变换。见附件。
 
我假设要真正符合3d,即使是非平面曲线,向量切线法线也始终指向曲率中心。这绝对是一个额外的问题。
交叉积。图纸

SEANT 发表于 2022-7-6 16:00:24

我想我还应该指出我的声明:
不是特别符合3d。它将返回X轴和向量投影到WCS之间的角度(我猜这就是您在原始帖子中寻找的)。
 
这两个矢量之间的真实3d角度必须考虑矢量3d。Z分量。矢量3D。GetAngleTo方法(X轴为Vector3d)。
页: 1 [2]
查看完整版本: 与cu相切的角度/斜率