On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.
Become a Premium Member and unlock a new, free course in leading technologies each month.
Private Sub GetCenterPoints(ByVal dbArcStartX As Double, ByVal dbArStartY As Double, _
ByVal dbArcEndX As Double, ByVal dbArcEndY As Double, ByVal dbRadius As Double)
Dim dbCenterPointX As Double
Dim dbCenterPointY As Double
MessageBox.Show("The center point = X " & dbCenterPointX & " Y " & dbCenterPointY)
End Sub
Arc.JPG
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Private Shared Sub GetCirlce(ByVal dbArcStartX As Double, ByVal dbArStartY As Double, _
ByVal dbArcEndX As Double, ByVal dbArcEndY As Double, _
ByVal dbArcMidX As Double, ByVal dbArcMidY As Double, _
ByRef dbArcCenterX As Double, ByRef dbArcCenterY As Double, _
ByRef dbArcStartAngle As Double, ByRef dbArcEndAngle As Double, _
ByRef dbArcRadius As Double)
Dim dbUnknown1 As Double
Dim dbUnknown2 As Double
Dim dbUnknown3 As Double
Dim dbUnknown4 As Double
Dim dbUnknown5 As Double
Dim dbUnknown6 As Double
'Unknown
dbUnknown2 = (2 * dbArcStartX * (2 * dbArcEndY - 2 * dbArcMidY) - 2 * dbArStartY * (2 * dbArcEndX - 2 * dbArcMidX) + 4 * dbArcEndX * dbArcMidY - 4 * dbArcEndY * dbArcMidX)
'Get the arc center point for X
dbArcCenterX = ((dbArcStartX ^ 2 + dbArStartY ^ 2) * (2 * dbArcEndY - 2 * dbArcMidY) - 2 * dbArStartY * (dbArcEndX ^ 2 + dbArcEndY ^ 2 - dbArcMidX ^ 2 - dbArcMidY ^ 2) + 2 * dbArcMidY * (dbArcEndX ^ 2 + dbArcEndY ^ 2) - 2 * dbArcEndY * (dbArcMidX ^ 2 + dbArcMidY ^ 2)) / dbUnknown2
'Get the arc center point for X
dbArcCenterY = (2 * dbArcStartX * (dbArcEndX ^ 2 + dbArcEndY ^ 2 - dbArcMidX ^ 2 - dbArcMidY ^ 2) - (dbArcStartX ^ 2 + dbArStartY ^ 2) * (2 * dbArcEndX - 2 * dbArcMidX) + 2 * dbArcEndX * (dbArcMidX ^ 2 + dbArcMidY ^ 2) - 2 * dbArcMidX * (dbArcEndX ^ 2 + dbArcEndY ^ 2)) / dbUnknown2
'Unknown
dbUnknown1 = (2 * dbArcStartX * (2 * dbArcEndY * (dbArcMidX ^ 2 + dbArcMidY ^ 2) - 2 * dbArcMidY * (dbArcEndX ^ 2 + dbArcEndY ^ 2)) - 2 * dbArStartY * (2 * dbArcEndX * (dbArcMidX ^ 2 + dbArcMidY ^ 2) - 2 * dbArcMidX * (dbArcEndX ^ 2 + dbArcEndY ^ 2)) + (dbArcStartX ^ 2 + dbArStartY ^ 2) * (4 * dbArcEndX * dbArcMidY - 4 * dbArcEndY * dbArcMidX)) / dbUnknown2
'Get the arc radius
dbArcRadius = Math.Sqrt(dbUnknown1 + dbArcCenterX ^ 2 + dbArcCenterY ^ 2)
If dbArcCenterX < dbArcStartX And dbArcCenterY <> dbArStartY Then
dbArcStartAngle = Math.Atan((dbArStartY - dbArcCenterY) / (dbArcStartX - dbArcCenterX)) * 180 / 3.1415927
End If
If dbArcCenterX > dbArcStartX And dbArcCenterY <> dbArStartY Then
dbArcStartAngle = 180 - Math.Atan((dbArStartY - dbArcCenterY) / (dbArcCenterX - dbArcStartX)) * 180 / 3.1415927
End If
If dbArcCenterX = dbArcStartX And dbArcCenterY < dbArStartY Then
dbArcStartAngle = 90
End If
If dbArcCenterX < dbArcStartX And dbArcCenterY = dbArStartY Then
dbArcStartAngle = 0
End If
If dbArcCenterX = dbArcStartX And dbArcCenterY > dbArStartY Then
dbArcStartAngle = -90
End If
If dbArcCenterX > dbArcStartX And dbArcCenterY = dbArStartY Then
dbArcStartAngle = 180
End If
dbUnknown3 = 1 - (((dbArcStartX - dbArcMidX) ^ 2 + (dbArStartY - dbArcMidY) ^ 2) / (2 * (dbArcRadius ^ 2)))
If dbUnknown3 <> 1 And dbUnknown3 <> -1 Then
dbArcEndAngle = Math.Atan(-dbUnknown3 / Math.Sqrt(1 - (dbUnknown3 ^ 2))) * 180 / 3.1415927 + 90
End If
If dbUnknown3 = -1 Then
dbArcEndAngle = 180
End If
dbUnknown6 = (dbArcMidX - dbArcStartX)
If dbUnknown6 <> 0 Then
dbUnknown5 = (dbArcMidY - dbArStartY) / dbUnknown6
End If
dbUnknown4 = dbUnknown5 * (dbArcEndX - dbArcStartX) + dbArStartY
If dbArcStartX < dbArcMidX And dbArcEndY > dbUnknown4 Then
dbArcEndAngle = dbArcEndAngle * (-1)
End If
If dbArcStartX > dbArcMidX And dbArcEndY < dbUnknown4 Then
dbArcEndAngle = dbArcEndAngle * (-1)
End If
If dbArcStartX = dbArcMidX And dbArcMidY > dbArStartY And dbArcEndX < dbArcStartX Then
dbArcEndAngle = dbArcEndAngle * (-1)
End If
If dbArcStartX = dbArcMidX And dbArcMidY < dbArStartY And dbArcEndX > dbArcStartX Then
dbArcEndAngle = dbArcEndAngle * (-1)
End If
End Sub
Public Function DrawArc(ByVal StartPoint As PointF, ByVal EndPoint As PointF, ByVal Radius As Single, ByVal Clockwise As Boolean, ByRef sngStartAngle As Single, ByRef sngEndAngle As Single)
Try
' Find the point that corresponds to the midpoint of the line.
Dim pLineMidPoint As New PointF((StartPoint.X + EndPoint.X) / 2, (StartPoint.Y + EndPoint.Y) / 2)
' Calculate 1/2 the distance between the start and end point.
Dim sngMidpointDistance As Single = PointDistance(StartPoint, pLineMidPoint)
' If 1/2 between the two points is greater than the radius, then a
' circular segment cannot be draw. Instead, draw a straight line
' between the two points.
If sngMidpointDistance > Radius Then
Return False
End If
' Find the slope of a line drawn between the start and end point.
Dim sngLineSlope As Single = GetSlope(StartPoint, EndPoint)
' Find the distance between the midpoint of the line and the midpoint
' of the arc.
Dim sngDistanceToCenterPoint As Single = CSng(Math.Sqrt(Radius ^ 2 - sngMidpointDistance ^ 2))
' Find the mid point of the arc.
Dim pOffset As New PointF(0, sngDistanceToCenterPoint)
If Not Clockwise Then pOffset.Y *= -1
Dim pArcMidpoint As PointF = OffsetPointsByAngle(pLineMidPoint, pOffset, sngLineSlope)
' Build a bounding box to hold the arc.
Dim rCircle As New RectangleF(pArcMidpoint.X - Radius, (pArcMidpoint.Y - Radius), Radius * 2, Radius * 2)
' Find the starting angle.
sngStartAngle = 360 - GetSlope(pArcMidpoint, StartPoint)
' Find the the ending angle.
sngEndAngle = 360 - GetSlope(pArcMidpoint, EndPoint)
If sngEndAngle < sngStartAngle Then sngEndAngle += 360
' Convert the ending angle to the number of degrees between the start
' and end angle.
sngEndAngle = Math.Abs(sngStartAngle - sngEndAngle)
If Not Clockwise Then sngEndAngle = sngEndAngle - 360
Return True
Catch ex As Exception
Return False
End Try
End Function
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.