I want to start off by apologizing if this is an improper use of the forums. At first glance, this didn't seem like a terrible place to ask this question.
I've been asked to code a script that will take data from a set of spatial coordinates (essentially a probe moving around inside of a body), and arrange it into an array so that it can be visualized digitally.
Is this a terribly difficult thing to do? Or could I start learning how to build this script from scrap right now? I have taken a few C++ classes that weren't very heavy coding intensive, but were very instructive and I learned a lot, so I think I'm in place to at least direct my learning how I see fit to accomplish what I need to do.
So the data looks like this. I'm not sure how to make any sense of it, but they basically just want to plot it in 3d so they can look at in in 3d.
PHI =0:dPHI:num_of_turns*2*pi;
Z = Z0+c*(PHI)/2/pi;
X = R0.*cos(PHI)*scale;
Y = R0.*sin(PHI)*scale;
Z = (Z+Zstart)*scale;
hold on
plot3(X,Y,Z)
axis equal
coords_all = [X' Y' Z'];
%%%%%helix export in .csv format
csvwrite([filename,'.csv'],coords_all)
%%%%%%%%%%%%%%% G CODE MAKING %%%%%%%%%%
%%%%%%%% Calculation of linear displacement of pump plunger
dist=0;
for i=2:length(X)
dist=dist+sqrt((X(i)-X(i-1))^2+(Y(i)-Y(i-1))^2+(Z(i)-Z(i-1))^2);
end
pump_dist= dist/speed*flowrate/3600/dia;
pump_step=pump_dist/(length(X)-1);
A = [0:pump_step:((length(X)-1)*pump_step)];
fid=fopen([filename,'.job'],'wt'); % starts the .job file
gcode=['G21'];%chage the units to mm %%% use G20 in case of inches
count=fprintf(fid,'%s\n',gcode);
%set the first coordinate point to zero
gcode=['G92 X' ,num2str(X(1),'%6.3f') , ' Y' ,num2str(Y(1),'%6.3f') , ' Z' ,num2str(Z(1),'%6.3f') , ' A' ,num2str(A(1),'%6.5f')];
count=fprintf(fid,'%s\n',gcode);
%first coordinate point + speed
gcode=['G1 X' ,num2str(X(1),'%6.3f') ,' Y' ,num2str(Y(1),'%6.3f'),' Z' ,num2str(Z(1),'%6.3f') ,' A' ,num2str(A(1),'%6.5f') ,' F' , num2str(speed*60,'%2g') ];
count=fprintf(fid,'%s\n',gcode);
%rest of the code
for line=2:length(X)
gcode=['G1 X' ,num2str(X(line),'%6.3f') ,' Y' ,num2str(Y(line),'%6.3f') ,' Z' ,num2str(Z(line),'%6.3f') ,' A' ,num2str(A(line),'%6.5f')];
count=fprintf(fid,'%s\n',gcode);
end
a) If you have the data then provided it is readable by gnuplot then it will display that data in 3d.
e.g. http://lowrank.net/gnuplot/plot3d2-e.html
http://www.gnuplotting.org/plotting-data/
b) If you don't have 3d data and just the mathematical function for an object then you can program gnuplot to plot that.
http://lowrank.net/gnuplot/plot3d-e.html as above
http://www.gnuplotting.org/plotting-functions/
Whichever one you are attempting 2d and 3d capabilities are the same. You can check them out, they're easy to find.
There is a lot of reference material on the web if you want to interface gnuplot with c++ :)
If you have the data then provided it is readable by gnuplot
Adding to that: since it seems that you can modify the code that writes the data to a file, you can change the file format to make it readable by gnuplot.