Results 1 to 12 of 12

Thread: [RESOLVED] How to get Equal Parts or Equal Radians in a Circle ?

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2024
    Posts
    133

    Resolved [RESOLVED] How to get Equal Parts or Equal Radians in a Circle ?

    Hello

    Does anyone know how to get Equal parts or Equal Radians in a Circle for the below defined case?
    Have attached image for your reference ? Img1

    In this case I've tried to divide Circle by 16 parts somehow I am getting 17 parts.
    Can anyone help me to achieve the Exact result of 16 parts. Even in the Image 1, between the two red line marked,
    shows the extra 17th part.

    How can I avoid showing the 17th part and therefore all the radians to be of Equal.

    Below in code I've taken MOD 22, although 360 / 16 = 22.5. I don't know what needs to be taken as 22 or 22.5

    Also I tried to fill the Radians. But did not come correctly. ie. because I could not match the correct points
    Img2 is derived by below coding

    So how to achieve as per image1, ie by Filling 8 radians alternately if 16 parts are equally divided
    Img1(Could be untidy as edited in MS-Paint) .

    Code:
    Private newImg As New Bitmap(700, 700)
    Private gr As Graphics = Graphics.FromImage(newImg)
    
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
       cPoint = New Point(newImg.Width / 2, newImg.Width / 2)
       Dim radiuss As Integer = newImg.Width / 2
       EqualFacesInCircle(gr, cPoint, radiuss)
    End Sub
    
    Private Sub EqualFacesInCircle(ByVal gr As Graphics, ByVal centre As PointF, ByVal radius As Single)
    
       Dim bluePen As New Pen(Color.Blue, 2)
    
    
    For i As Integer = 0 To 359
                Dim angle As Double = Math.PI * 2 * i / 360 ' Calculate angle for each line
    
                ' outer point of the line
                Dim outerX As Single = centre.X + CSng(Math.Cos(angle) * radius)
                Dim outerY As Single = centre.Y + CSng(Math.Sin(angle) * radius)
    
                ' Inner point of the tick mark
                Dim lengthOfTickMark As Integer = 17.5
    
                Dim innerRadius As Integer = If(i Mod 22 = 0, radius - lengthOfTickMark, Nothing)
    
                Dim LongerInnerX As Single = centre.X + CSng(Math.Cos(angle) * innerRadius)
                Dim LongerInnerY As Single = centre.X + CSng(Math.Sin(angle) * innerRadius)
    
                'Dim sldBrBlue As New SolidBrush(Blue)
    
              Dim lemonAppealBrush As SolidBrush = New SolidBrush(Color.FromArgb(239, 227, 175))
    
                If i Mod 22 = 0 Then
                    gr.DrawLine(bluePen, New PointF(outerX, outerY), New PointF(centre.X, centre.Y))
    
                    Dim point1 As Point = New Point(centre.X, centre.Y) '(newXCentPoint, newYCentPoint)  'Centre (350,350) 
                    Dim point2 As Point = New Point(centre.X, outerY) '(newXCentPoint, y1) '(350, 50) 'Top Centre
                    Dim point3 As Point = New Point(outerX, centre.Y) '(newXCentPoint + HalfEdgeSqWidth, newYCentPoint) '(650, 350) 'Centre to Right
    
                    Dim curvePoints1 As Point() = {point1, point2, point3}
                    gr.FillPolygon(lemonAppealBrush, curvePoints1)
    
                End If
    
            Next
    
            PictureBox1.Image = newImg
    
    
    End Sub
    EDIT: I tried to fill up color for all the radians
    Your help will be appreciated.

    Thanks
    nkvb
    Attached Images Attached Images   
    Last edited by nkvb; Jan 24th, 2025 at 02:11 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width