Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. GDI+ randomly select point on a drawn circle

GDI+ randomly select point on a drawn circle

Scheduled Pinned Locked Moved C / C++ / MFC
questionwinformsgraphics
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mpastchenko
    wrote on last edited by
    #1

    This is another GDI+ question: Does anyone know how it is possible to randomly /select/draw/get coordinates of/ a point on a circle line of drawn circle? Thanks in advance, Sincerely, Max Pastchenko

    C B 2 Replies Last reply
    0
    • M mpastchenko

      This is another GDI+ question: Does anyone know how it is possible to randomly /select/draw/get coordinates of/ a point on a circle line of drawn circle? Thanks in advance, Sincerely, Max Pastchenko

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      do you know the center and radius of the circle ? Cleek | Image Toolkits | Thumbnail maker

      1 Reply Last reply
      0
      • M mpastchenko

        This is another GDI+ question: Does anyone know how it is possible to randomly /select/draw/get coordinates of/ a point on a circle line of drawn circle? Thanks in advance, Sincerely, Max Pastchenko

        B Offline
        B Offline
        Bob Flynn
        wrote on last edited by
        #3

        You question is not entirely clear. From a general perspective if you need to generate a random point on the circumference of a circle you could generate a random number between [0,360)and then, given that you know the radius and centerpoint of the circle transform your random angle to get the coordinates you need. I do not know what built in function there are for this, but simple geometry will give you the coordinates. You know the origin (centerpoint of your circle) which is a general (x,y) pair. You now also know the angle of a triangle and the length of the hypotenuse. Use trig to compute the x and y offsets: r * sin(theta) = y; r * cos(theta) = x. I hope this helps. Check my math, my trig my be rusty.

        M 1 Reply Last reply
        0
        • B Bob Flynn

          You question is not entirely clear. From a general perspective if you need to generate a random point on the circumference of a circle you could generate a random number between [0,360)and then, given that you know the radius and centerpoint of the circle transform your random angle to get the coordinates you need. I do not know what built in function there are for this, but simple geometry will give you the coordinates. You know the origin (centerpoint of your circle) which is a general (x,y) pair. You now also know the angle of a triangle and the length of the hypotenuse. Use trig to compute the x and y offsets: r * sin(theta) = y; r * cos(theta) = x. I hope this helps. Check my math, my trig my be rusty.

          M Offline
          M Offline
          mpastchenko
          wrote on last edited by
          #4

          This is quite helpful. Thank you Sincerely, Max Pastchenko

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups