tmp
This commit is contained in:
@@ -13,6 +13,8 @@ macro(add_example name switch)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
add_example(gnuplot_ex ON)
|
||||
|
||||
if(${GCTL_GRAPHIC_GMT})
|
||||
add_example(JX_single_ex ON)
|
||||
endif()
|
||||
|
70
example/gnuplot_ex.cpp
Normal file
70
example/gnuplot_ex.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/********************************************************
|
||||
* ██████╗ ██████╗████████╗██╗
|
||||
* ██╔════╝ ██╔════╝╚══██╔══╝██║
|
||||
* ██║ ███╗██║ ██║ ██║
|
||||
* ██║ ██║██║ ██║ ██║
|
||||
* ╚██████╔╝╚██████╗ ██║ ███████╗
|
||||
* ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝
|
||||
* Geophysical Computational Tools & Library (GCTL)
|
||||
*
|
||||
* Copyright (c) 2022 Yi Zhang (yizhang-geo@zju.edu.cn)
|
||||
*
|
||||
* GCTL is distributed under a dual licensing scheme. You can redistribute
|
||||
* it and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation, either version 2
|
||||
* of the License, or (at your option) any later version. You should have
|
||||
* received a copy of the GNU Lesser General Public License along with this
|
||||
* program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* If the terms and conditions of the LGPL v.2. would prevent you from using
|
||||
* the GCTL, please consider the option to obtain a commercial license for a
|
||||
* fee. These licenses are offered by the GCTL's original author. As a rule,
|
||||
* licenses are provided "as-is", unlimited in time for a one time fee. Please
|
||||
* send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget
|
||||
* to include some description of your company and the realm of its activities.
|
||||
* Also add information on how to contact you by electronic and paper mail.
|
||||
******************************************************/
|
||||
|
||||
#include "../lib/graphic.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
gctl::gnuplot gt;
|
||||
//one line test
|
||||
//gt.send("plot [-pi/2:pi] cos(x),-(sin(x) > sin(x+1) ? sin(x) : sin(x+1))");
|
||||
|
||||
//buffer test (bessel animation)
|
||||
gt.to_buffer();
|
||||
gt.send("set terminal gif animate delay 10 size 600,400");
|
||||
gt.send("set output 'bessel.gif'");
|
||||
gt.send("set palette rgb 3,9,9");
|
||||
gt.send("unset key; unset colorbox; unset border; unset tics");
|
||||
gt.send("set lmargin at screen 0.03");
|
||||
gt.send("set bmargin at screen 0");
|
||||
gt.send("set rmargin at screen 0.97");
|
||||
gt.send("set tmargin at screen 1");
|
||||
gt.send("set parametric", true);
|
||||
gt.send("bessel(x,t) = besj0(x) * cos(2*pi*t)");
|
||||
gt.send("n = 6 # number of zeros");
|
||||
gt.send("k = (n*pi-1.0/4*pi)");
|
||||
gt.send("u_0 = k + 1/(8*k) - 31/(384*k)**3 + 3779/(15360*k)**5");
|
||||
gt.send("set urange [0:u_0]");
|
||||
gt.send("set vrange[0:1.5*pi]");
|
||||
gt.send("set cbrange [-1:1]");
|
||||
gt.send("set zrange[-1:1]");
|
||||
gt.send("set isosamples 200,100");
|
||||
gt.send("set pm3d depthorder");
|
||||
gt.send("set view 40,200");
|
||||
|
||||
std::string cmd;
|
||||
for (float t = 0.0f; t < 2.0f; t += 0.02f)
|
||||
{
|
||||
cmd = "splot u*sin(v),u*cos(v),bessel(u," + std::to_string(t) + ") w pm3d ls 1";
|
||||
gt.send(cmd);
|
||||
}
|
||||
gt.send("set output");
|
||||
|
||||
gt.save_buffer("bessel");
|
||||
gt.send_buffer();
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user