Hi,
I am trying to find included angle for a circle segment.
See attached image.(i need to find ang2).
all other yellow marked values are i have.
Below is my code. But result is not correct.
Whats wrong with my code? any idea?
-----------------------------------------------------------
Dim P1 As Point2d = New Point2d(0, 0)
Dim Pt1 As Point2d = Util.PolarPoint(P1, ang1, r)
Dim Pt2 As Point2d = Util.PolarPoint(Pt1, ang1 + 90, d / 2)
Dim Pt3 As Point2d = Util.PolarPoint(Pt1, ang1 - 90, d / 2)
Dim acV1 As Vector2d = dblOrginPt.GetVectorTo(Pt2)
Dim acV2 As Vector2d = dblOrginPt.GetVectorTo(Pt3)
Dim ang2 As Double = acV1.GetAngleTo(acV2)
-----------------------------------------------------------
note: i didn't follow any coding std for above piece of code.
please excuse me for that.
Thanks & regards,
g
Solved! Go to Solution.
Solved by cadMeUp. Go to Solution.
I believe the PolarPoint method of the AcadUtility object expects the angle parameter to be in radians:
Dim rad90 As Double = Math.PI / 2
Dim Pt2 As Point2d = Util.PolarPoint(Pt1, ang1 + rad90, d / 2)
Dim Pt3 As Point2d = Util.PolarPoint(Pt1, ang1 - rad90, d / 2)
also make sure that the ang1 var is in radians.
I didn't test your code though, hopefully that will get it working correctly.
Hi,
You are correct.
That polarpoint method in my util class requires angle in radians.
Now everything is working fine.
Thank you very much for your timely help
Regards
G
Also, if you are just getting the points to calculate the angle you can avoid the PolarPoint method. As long as you know the radius and the offset distance you can use a little trig to calculate the angle:
Dim r As Double = 10
Dim d As Double = 4
'Get one half of the needed angle, in radians
Dim halfAngRad As Double = Math.Atan(1 / (r / (d / 2)))
'Convert the half angle to degrees
Dim halfAng As Double = (halfAngRad / Math.PI) * 180
'To get the total angle in degrees multiply by 2
Dim incAng As Double = halfAng * 2
incAng will equal 22.6198649480404
and you could combine them into one statement:
Dim incAng As Double = ((Math.Atan(1 / (r / (d / 2))) / Math.PI) * 180) * 2
Hi,
That is great!
I always forgot about geometrical ideas to find solution when i am doing program! that's shame for me.
Thank you very much for your valuable guidance.
I really very much like this discussion board where i can find all the answers from these huge discussions.
Thanks all genius to share their knowledge here.
Regards,
G