圆和空间任意直线垂直公式
要求是有一个圆的圆心,在空间任意直线a-b的一个端点.
求一个通用公式,实现圆要与空间任意直线垂直的要求.
图示效果见http://www.mjtd.com/bbs/dispbbs.asp?boardID=37&ID=58148&page=1
原因是在Autocad可中画圆,须在X-Y平面完成,用VB处理UCS编程方法麻烦.有个数学公式,简单明了.
我现在做法比较麻烦,下面的例子用反正切方法解绕Z轴的公式,需要多个判断语句实现,请问各位大侠,有更好的解法吗??????
Function RotateZ_Axis(ByVal sPoint As Variant, ByVal ePoint As Variant) As Double
Dim EntAngle As Double
Dim deltaX As Double, deltaY As Double, deltaZ As Double
deltaX = sPoint(0) - ePoint(0): deltaY = sPoint(1) - ePoint(1): deltaZ = sPoint(2) - ePoint(2):
If deltaY > = 0 And deltaX > 0 Then
EntAngle = Atn(deltaY / deltaX)
ElseIf deltaY > = 0 And deltaX < 0 Then
EntAngle = Pi + Atn(deltaY / deltaX)
ElseIf deltaY < 0 And deltaX < 0 Then
EntAngle = Pi + Atn(deltaY / deltaX)
ElseIf deltaY < 0 And deltaX > 0 Then
EntAngle = 2 * Pi + Atn(deltaY / deltaX)
End If
If deltaX = 0 Then
If deltaY > 0 Then
EntAngle = Pi / 2
ElseIf deltaY > 0 Then
EntAngle = Pi * 1.5
End If
End If
RotateZ_Axis = EntAngle
End Function
Function RotateX_Axis(txtEnt As String) As Double
Dim Ent As AcadLine
Dim EntAngle As Double
Set Ent = ThisDrawing.HandleToObject(txtEnt)
If deltaY > = 0 And deltaX > 0 Then
EntAngle = Atn(deltaY / deltaX)
ElseIf deltaY > = 0 And deltaX < 0 Then
EntAngle = Pi + Atn(deltaY / deltaX)
ElseIf deltaY < 0 And deltaX < 0 Then
EntAngle = Pi + Atn(deltaY / deltaX)
ElseIf deltaY < 0 And deltaX > 0 Then
EntAngle = 2 * Pi + Atn(deltaY / deltaX)
End If
If deltaX = 0 Then
If deltaY > 0 Then
EntAngle = Pi / 2
ElseIf deltaY > 0 Then
EntAngle = Pi * 1.5
End If
End If
RotateZ_Axis = EntAngle
End Function
RotateZ_Axis,RotateX_Axis,RotateY_Axis返回的的是直线在X,Y,Z坐标轴的方向角。
用
L=SQR(dx^2+dy^2+dz^2)方程。
alfa = (x - x1) / Sqr((x - x1) ^ 2 + (y - y1) ^ 2 + (z - z1) ^ 2) 绕X轴
beta = (y - y1) / Sqr((x - x1) ^ 2 + (y - y1) ^ 2 + (z - z1) ^ 2) 绕Y轴
theta = (z - z1) / Sqr((x - x1) ^ 2 + (y - y1) ^ 2 + (z - z1) ^ 2) 绕Z轴
也还需要很多判断语句
请教各位大侠是否还有其它什么公式可以一次性解决.
[解决办法]
线性数学忘的差不多了~