How to draw a sphere

  • FeynmanLogomaker
    26th Nov 2013 Member 0 Permalink

    I know this isn't exactly related to TPT, but...

     

    Does anyone know of a way to draw a sphere programmatically? 

    (It would be preferable to just straight–out give me a function that could do it, assuming that the command to draw a quadrilateral is quad(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4). I could also make do if it used triangles instead.)

  • RadioActiveLua
    1st Dec 2013 Member 0 Permalink

    @nucular (View Post)

    lol'd so hard.

     

  • Cacophony
    1st Dec 2013 Member 1 Permalink

    It was,like, so hard! Like,I couldn't,like,watch,like,the,like, googling thingy, like. google the result, and like,I couldn't,like,figure out which,like,link to,like,click, so I just,like,clicked the first one! Like,I couldn't,like,read of that like,smart person talk,so I like,restarted the,like,computer because I,like, thought it was,like, my computer.But it,like,wasn't so I,like,went back to looking at,like,myself in the,like,mirror.

    Edited 6 times by Cacophony. Last: 1st Dec 2013
  • FeynmanLogomaker
    1st Dec 2013 Member 0 Permalink

    @nucular (View Post)

     Thanks for giving me another link to add on to my ever-growing collection of sphere-drawing-related searches. You don't suppose that was the very first thing I did?

  • boxmein
    1st Dec 2013 Former Staff 0 Permalink
    @FeynmanLogomaker (View Post)
    The general equation for a sphere is
    image
    (where r is the radius of the sphere)
    so you can work from that. Alternatively, if you're using C++ and OpenGL, you could look at this StackOverflow answer or, if you use a version of GLUT then you could use glutSolidSphere as your starting point.

    ... and all that was obtained with one Google search and a bit of previous knowledge.
    Edited 3 times by boxmein. Last: 1st Dec 2013
  • FeynmanLogomaker
    2nd Dec 2013 Member 0 Permalink

    I know all that. I literally looked at the first 50 results for 10 or so different Google searches.

  • mniip
    2nd Dec 2013 Developer 0 Permalink
    to draw a sphere you just transform its center coordinates and keep the radius. You get a circle, that's what the sphere looks like
  • FeynmanLogomaker
    2nd Dec 2013 Member 0 Permalink

    I tried it, but it didn't have any shading (I'm using LuaGL, so that's pretty much required)