Anyone has an idea to generate points for a solid sphere in C++ that can
be
plotted with gnuplot? I have tried to plot simple functions based on
output
from a function written in C++ which worked fine, but am not sure how to
deal with solid object like a sphere from C++.
Generating the points isn't very hard, but by themselves, those will be
pretty useless -- if you just plot the points, there won't be a visible
difference between a sphere and a flat circle.
If you want to generate something recognizably sphere-like in gnuplot,
it's probably easier (and faster) to let gnuplot generate the points
itself anyway, something like this:
set nokey
set parametric
set hidden3d
set view 60
set isosamples 40, 30
set xrange[-2 : 2]
set yrange[-2 : 2]
set zrange[-1 : 1]
splot [-pi
i][-pi/2
i/2] cos(u)*cos(v), sin(u)*cos(v), sin(v)
This will give a wireframe model. If you _really_ want something that
looks like a solid surface, you'll need to do define lights and the
characteristics of the surface being modeled, then calculate the color
for each point on the surface. My immediate guess is that gnuplot won't
be of much help for this job -- you'd be much better off using something
like OpenGL that supports such things directly.