绘制角度拱,或如何为连续(重新)绘图

时间:2016-11-15 20:36:19

标签: gnuplot

我正在尝试在单位球体中创建一些矢量的三维图,其中一些矢量之间具有角拱。 这是current situation注意:我目前只尝试了两个角拱,但最后还需要更多。

为了添加拱门,我将自己定位于以下教程(接近结束'3D Case'):http://www.gnuplotting.org/tag/circle/

问题是,他们使用urangevrange来限制拱门的角度。他们可以这样做,因为他们在示例中只有两个角度,而不是像我一样多。

因此,凭借我有限的数学和gnuplot知识,我将某些东西整合在一起: my angle arches attempt

什么样的笨蛋是,从我的角拱的'末端'到0,0,0的线被绘制,甚至在我指定的箭头顶部。

有没有办法用不同的urangevrange绘制每个拱门?类似的东西:

splot cos(u)*cos(v),cos(u)*sin(v),sin(u) notitle lc rgb "#B0000000" linetype 2,\
    [-pi/2:pi/2][0:2*pi] fvx(v),fvy(v),fvz lc rgb "#7878ff" linetype 1,\
    [-pi/2:0][0:2*pi] fux(u),fuy(u),fuz(u)

还是有些东西我完全失踪了?

到目前为止,这是我的代码..:

set xrange [-1:1]
set yrange [-1:1]
set zrange [-1:1]

set xyplane at 0 #z axis 0 should be on xy-plane


set parametric

set urange [-pi/2:pi/2]
set vrange [0:2*pi]

set key off

#view schraeg: 32,320
set view 32,320, 1,1
set style arrow 1 linecolor rgb "#FF0000"
set style arrow 2 linecolor rgb "#ff5252" 
set style arrow 3 linecolor rgb "#0000FF" 
set style arrow 4 linecolor rgb "#0000FF" nohead
set style arrow 6 linecolor rgb "#880000FF" nohead
set style arrow 5 linecolor rgb "#FF0000" nohead

# Angle between m' and x axis
r0 = 0.1
fvx(v) = v<2.5793017540894563 ? r0*cos(v) : 0
fvy(v) = v<2.5793017540894563 ? r0*sin(v) : 0
fvz = 0

# Angle between n and m
r = 0.5
fux(u) = u >= 0.7915660086835659 ? r*cos(u)*cos(2.5793017540894563) : 0
fuy(u) = u >= 0.7915660086835659 ? r*cos(u)*sin(2.5793017540894563) : 0
fuz(u) = u >= 0.7915660086835659 ? r*sin(u) : 0

splot cos(u)*cos(v),cos(u)*sin(v),sin(u) notitle lc rgb "#B0000000" linetype 2,\
    fvx(v),fvy(v),fvz lc rgb "#7878ff" linetype 1,\
    fux(u),fuy(u),fuz(u)

set arrow from 0,0,0 to 1,0,0 nohead # x axis       
set arrow from 0,0,0 to 0,1.5,0 nohead # y axis
set arrow from 0,0,0 to 0,0,2 nohead # z axis

set arrow from 0,0,0 to 0.49999999999999994, 0, 0.8660254037844387 arrowstyle 1     #light
set arrow from 0,0,0 to 0.49999999999999994, 0, 0 arrowstyle 5      #light 1
set arrow from 0.49999999999999994, 0, 0 to 0.49999999999999994, 0, 0.8660254037844387 arrowstyle 5     #light 2
set arrow from 0,0,0 to -0.49999999999999994, 0, 0.8660254037844387 arrowstyle 2        #specular
set arrow from 0,0,0 to -0.6078313957973345, 0.3830222215594889, 0.6955824696430309 arrowstyle 3        #measure
set arrow from 0,0,0 to -0.6078313957973345, 0.3830222215594889, 0 arrowstyle 6                         #measure flat
set arrow from 0,0.3830222215594889,0 to -0.6078313957973345, 0.3830222215594889, 0 arrowstyle 6        #measure 1
set arrow from -0.6078313957973345,0,0 to -0.6078313957973345, 0.3830222215594889, 0 arrowstyle 6       #measure 2
set arrow from -0.6078313957973345, 0.3830222215594889, 0 to -0.6078313957973345, 0.3830222215594889, 0.6955824696430309 arrowstyle 4       #measure 3


pause -1

1 个答案:

答案 0 :(得分:0)

如果你不能指定范围(因为你使用replot方法,这是明智的),那么,改变功能!

您可以更改变量以适应任何其他范围。说:

set parametric
set urange [0:pi]
splot 0,0,0 # because internal variables are not initialised else, this will not be a problem in your example.
CoV(u,min,max)=min+(u-GPVAL_U_MIN)*(max-min)/(GPVAL_U_MAX-GPVAL_U_MIN)
splot cos(CoV(u,pi/3,pi/2)),sin(CoV(u,pi/3,pi/2)),0

CoV(变量的变化)在绘图时使用变量u的范围(Gnuplot变量GPVAL_U_*)以在规定的最小值和最大值之间重新缩放u。丑陋的splot 0,0,0可能会使用stats命令保留未来版本的gnuplot,但尚未使用版本5.0。或者,最初可以设置自己的变量:

my_u_min=0.
my_u_max=pi
set urange [my_u_min:my_u_max]
U_MIN(dummy)=(exists("GPVAL_U_MIN")?GPVAL_U_MIN:my_u_min)
U_MAX(dummy)=(exists("GPVAL_U_MAX")?GPVAL_U_MAX:my_u_max)
CoV(u,min,max)=min+(u-U_MIN(0))*(max-min)/(U_MAX(0)-U_MIN(0))