- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个完整城市的 3D 模型,想展示一个
这些建筑物的等距 View 。我为此使用 gnuplot 多边形,
因为我不认为我可以将 pm3d 用于具有坐标的多边形
不在一个明确定义的网格上。多边形以颜色显示
对应于他们获得的平均太阳辐照度。一世
还将地面多边形显示为线框,主要用于设置 xrange,
yrange 和 zrange 自动。
远看还可以,但是放大后会发现
某些多边形的深度顺序是错误的。
这是导入 SketchUp 的 CityGML 模型:
这就是 Gnuplot 的结果:
你知道我如何以正确的顺序显示这些多边形吗?
类似 this会很棒,但它似乎只适用于 splot
.
这是一个 Gnuplot 文件来查看问题(2 个建筑物和 4 个屋顶):
set style line 1 linecolor rgbcolor "#777777" linewidth 1
set style increment user
set palette file "-"
0.00000 0.23137 0.22353 0.64314
0.17990 0.47843 0.34510 0.71765
0.32010 0.34902 0.17647 0.55686
0.43990 0.40784 0.10980 0.36471
0.59010 0.46275 0.09020 0.16863
0.78000 0.86667 0.41569 0.24314
0.92990 0.92549 0.66667 0.33725
1.00000 0.97647 0.91765 0.82745
e
set cbrange [50:150]
set cbtics 25
set format cb "%.0f W/m²"
unset xtics
unset ytics
unset ztics
unset border
set colorbox
kzoom=1.0
phi=30.0
theta=60.0
set xyplane 0 # removes the offset of the xy plane
set view equal xyz # force equal units to all three axes
set view theta,phi,kzoom
set object 1 polygon from \
2.0,0.0,3.0 to \
3.0,0.0,3.5 to \
3.0,2.0,3.5 to \
2.0,2.0,3.0 to \
2.0,0.0,3.0
set object 1 fill solid 0.9 border lw 2 fc palette cb 128.1315 front
set object 2 polygon from \
4.0,0.0,3.0 to \
4.0,2.0,3.0 to \
3.0,2.0,3.5 to \
3.0,0.0,3.5 to \
4.0,0.0,3.0
set object 2 fill solid 0.9 border lw 2 fc palette cb 128.62192 front
set object 3 polygon from \
2.0,0.0,0.0 to \
4.0,0.0,0.0 to \
4.0,0.0,3.0 to \
3.0,0.0,3.5 to \
2.0,0.0,3.0 to \
2.0,0.0,0.0
set object 3 fill solid 0.9 border lw 2 fc palette cb 100.545204
set object 4 polygon from \
4.0,0.0,0.0 to \
4.0,2.0,0.0 to \
4.0,2.0,3.0 to \
4.0,0.0,3.0 to \
4.0,0.0,0.0
set object 4 fill solid 0.9 border lw 2 fc palette cb 85.58082
set object 5 polygon from \
4.0,2.0,0.0 to \
2.0,2.0,0.0 to \
2.0,2.0,3.0 to \
3.0,2.0,3.5 to \
4.0,2.0,3.0 to \
4.0,2.0,0.0
set object 5 fill solid 0.9 border lw 2 fc palette cb 55.88219
set object 6 polygon from \
2.0,2.0,0.0 to \
2.0,0.0,0.0 to \
2.0,0.0,3.0 to \
2.0,2.0,0.0
set object 6 fill solid 0.9 border lw 2 fc palette cb 85.25754
set object 7 polygon from \
2.0,2.0,0.0 to \
2.0,0.0,3.0 to \
2.0,2.0,3.0 to \
2.0,2.0,0.0
set object 7 fill solid 0.9 border lw 2 fc palette cb 85.25754
set object 8 polygon from \
0.0,0.0,3.0 to \
1.0,0.0,3.5 to \
1.0,2.0,3.5 to \
0.0,2.0,3.0 to \
0.0,0.0,3.0
set object 8 fill solid 0.9 border lw 2 fc palette cb 128.1315 front
set object 9 polygon from \
2.0,0.0,3.0 to \
2.0,2.0,3.0 to \
1.0,2.0,3.5 to \
1.0,0.0,3.5 to \
2.0,0.0,3.0
set object 9 fill solid 0.9 border lw 2 fc palette cb 128.62192 front
set object 10 polygon from \
0.0,0.0,0.0 to \
2.0,0.0,0.0 to \
2.0,0.0,3.0 to \
1.0,0.0,3.5 to \
0.0,0.0,3.0 to \
0.0,0.0,0.0
set object 10 fill solid 0.9 border lw 2 fc palette cb 100.545204
set object 11 polygon from \
2.0,0.0,0.0 to \
2.0,2.0,0.0 to \
2.0,2.0,3.0 to \
2.0,0.0,3.0 to \
2.0,0.0,0.0
set object 11 fill solid 0.9 border lw 2 fc palette cb 85.58082
set object 12 polygon from \
2.0,2.0,0.0 to \
0.0,2.0,0.0 to \
0.0,2.0,3.0 to \
1.0,2.0,3.5 to \
2.0,2.0,3.0 to \
2.0,2.0,0.0
set object 12 fill solid 0.9 border lw 2 fc palette cb 55.88219
set object 13 polygon from \
0.0,2.0,0.0 to \
0.0,0.0,0.0 to \
0.0,0.0,3.0 to \
0.0,2.0,0.0
set object 13 fill solid 0.9 border lw 2 fc palette cb 85.25754
set object 14 polygon from \
0.0,2.0,0.0 to \
0.0,0.0,3.0 to \
0.0,2.0,3.0 to \
0.0,2.0,0.0
set object 14 fill solid 0.9 border lw 2 fc palette cb 85.25754
splot "-" with lines notitle ls 1, NaN notitle palette
2.0 0.0 0.0
2.0 2.0 0.0
4.0 2.0 0.0
4.0 0.0 0.0
2.0 0.0 0.0
0.0 0.0 0.0
0.0 2.0 0.0
2.0 2.0 0.0
2.0 0.0 0.0
0.0 0.0 0.0
e
pause mouse
最佳答案
我找不到一个选项来说服 gnuplot 它应该自动设置多边形对象的深度顺序。我发现的唯一方法是以正确的顺序定义对象。然后 gnuplot 将它们中的每一个绘制在前一个的顶部,从而得到预期的结果。
删除 front
后以多边形为例说明符,这种方法改变了原始图片:
到这个(删除 front
后):
到这个(排序后):
我认为第三张图片是你想要的。
我使用了一个 python 脚本来对多边形进行排序,它基本上是:
set object x polygon from
开头线。 set view theta, phi
,它围绕 x 和 z 轴旋转多边形(暂时,仅用于排序)。 x
在 set object x polygon
. set object
线。 # poly.py
from math import cos, sin, pi
from re import sub, match, findall
class Polygon:
def __init__(self):
self.firstLine = ""
self.points = []
self.lastLine = ""
def __str__(self):
pointStrings = [",".join(map(str,point)) for point in self.points]
s = ""
s += self.firstLine
s += " to \\\n".join(pointStrings)
s += "\n"
s += self.lastLine
return s
def readObjectFromFile(self, f, firstObjectLine):
self.firstLine = firstObjectLine
line = f.readline()
while not match("set",line):
coordinates = findall("[\d.]+", line)
coordinates = tuple(float(x) for x in coordinates)
self.points.append(coordinates)
line = f.readline()
self.lastLine = line
return self
def meanAfterRotation(self, theta, phi):
cx = 0.0
cy = 0.0
cz = 0.0
theta = theta*pi/180.0
phi = phi*pi/180.0
for point in self.points:
x,y,z = point
x,y,z = (x, y*cos(theta) - z*sin(theta), y*sin(theta) + z*cos(theta))
x,y,z = (x*cos(phi) - y*sin(phi), x*sin(phi) + y*cos(phi), z)
cx, cy, cz = (cx + x, cy + y, cz + z)
n = len(self.points)
return (cx/n, cy/n, cz/n)
def setPosition(self, posIndex):
self.firstLine = sub("(\d+)", str(posIndex), self.firstLine, 1)
self.lastLine = sub("(\d+)", str(posIndex), self.lastLine, 1)
polygons = []
with open("poly_raw.dat") as f:
line = f.readline()
while line:
if line.strip() != "":
polygons.append(Polygon().readObjectFromFile(f,line))
line = f.readline()
polygons.sort(key = lambda x: x.meanAfterRotation(60,30)[1], reverse = True)
pos = 1
for p in polygons:
p.setPosition(pos)
pos += 1
for p in polygons:
print(p)
# poly.plt, gnuplot 4.6
# Does not work when interactively rotating the picture.
set style line 1 linecolor rgbcolor "#777777" linewidth 1
set style increment user
set palette file "-"
0.00000 0.23137 0.22353 0.64314
0.17990 0.47843 0.34510 0.71765
0.32010 0.34902 0.17647 0.55686
0.43990 0.40784 0.10980 0.36471
0.59010 0.46275 0.09020 0.16863
0.78000 0.86667 0.41569 0.24314
0.92990 0.92549 0.66667 0.33725
1.00000 0.97647 0.91765 0.82745
e
set cbrange [50:150]
set cbtics 25
set format cb "%.0f W/m²"
unset xtics
unset ytics
unset ztics
unset border
set colorbox
kzoom=1.0
phi=30.0
theta=60.0
set xyplane 0 # removes the offset of the xy plane
set view equal xyz # force equal units to all three axes
set view theta,phi,kzoom
#load "poly_raw.dat"
load "poly_sorted.dat"
set terminal png
#set output "raw.png"
set output "sorted.png"
splot "-" with lines notitle ls 1, NaN notitle palette
2.0 0.0 0.0
2.0 2.0 0.0
4.0 2.0 0.0
4.0 0.0 0.0
2.0 0.0 0.0
0.0 0.0 0.0
0.0 2.0 0.0
2.0 2.0 0.0
2.0 0.0 0.0
0.0 0.0 0.0
e
front
后未排序的多边形数据说明符:
set object 1 polygon from \
2.0,0.0,3.0 to \
3.0,0.0,3.5 to \
3.0,2.0,3.5 to \
2.0,2.0,3.0 to \
2.0,0.0,3.0
set object 1 fill solid 0.9 border lw 2 fc palette cb 128.1315
set object 2 polygon from \
4.0,0.0,3.0 to \
4.0,2.0,3.0 to \
3.0,2.0,3.5 to \
3.0,0.0,3.5 to \
4.0,0.0,3.0
set object 2 fill solid 0.9 border lw 2 fc palette cb 128.62192
set object 3 polygon from \
2.0,0.0,0.0 to \
4.0,0.0,0.0 to \
4.0,0.0,3.0 to \
3.0,0.0,3.5 to \
2.0,0.0,3.0 to \
2.0,0.0,0.0
set object 3 fill solid 0.9 border lw 2 fc palette cb 100.545204
set object 4 polygon from \
4.0,0.0,0.0 to \
4.0,2.0,0.0 to \
4.0,2.0,3.0 to \
4.0,0.0,3.0 to \
4.0,0.0,0.0
set object 4 fill solid 0.9 border lw 2 fc palette cb 85.58082
set object 5 polygon from \
4.0,2.0,0.0 to \
2.0,2.0,0.0 to \
2.0,2.0,3.0 to \
3.0,2.0,3.5 to \
4.0,2.0,3.0 to \
4.0,2.0,0.0
set object 5 fill solid 0.9 border lw 2 fc palette cb 55.88219
set object 6 polygon from \
2.0,2.0,0.0 to \
2.0,0.0,0.0 to \
2.0,0.0,3.0 to \
2.0,2.0,0.0
set object 6 fill solid 0.9 border lw 2 fc palette cb 85.25754
set object 7 polygon from \
2.0,2.0,0.0 to \
2.0,0.0,3.0 to \
2.0,2.0,3.0 to \
2.0,2.0,0.0
set object 7 fill solid 0.9 border lw 2 fc palette cb 85.25754
set object 8 polygon from \
0.0,0.0,3.0 to \
1.0,0.0,3.5 to \
1.0,2.0,3.5 to \
0.0,2.0,3.0 to \
0.0,0.0,3.0
set object 8 fill solid 0.9 border lw 2 fc palette cb 128.1315
set object 9 polygon from \
2.0,0.0,3.0 to \
2.0,2.0,3.0 to \
1.0,2.0,3.5 to \
1.0,0.0,3.5 to \
2.0,0.0,3.0
set object 9 fill solid 0.9 border lw 2 fc palette cb 128.62192
set object 10 polygon from \
0.0,0.0,0.0 to \
2.0,0.0,0.0 to \
2.0,0.0,3.0 to \
1.0,0.0,3.5 to \
0.0,0.0,3.0 to \
0.0,0.0,0.0
set object 10 fill solid 0.9 border lw 2 fc palette cb 100.545204
set object 11 polygon from \
2.0,0.0,0.0 to \
2.0,2.0,0.0 to \
2.0,2.0,3.0 to \
2.0,0.0,3.0 to \
2.0,0.0,0.0
set object 11 fill solid 0.9 border lw 2 fc palette cb 85.58082
set object 12 polygon from \
2.0,2.0,0.0 to \
0.0,2.0,0.0 to \
0.0,2.0,3.0 to \
1.0,2.0,3.5 to \
2.0,2.0,3.0 to \
2.0,2.0,0.0
set object 12 fill solid 0.9 border lw 2 fc palette cb 55.88219
set object 13 polygon from \
0.0,2.0,0.0 to \
0.0,0.0,0.0 to \
0.0,0.0,3.0 to \
0.0,2.0,0.0
set object 13 fill solid 0.9 border lw 2 fc palette cb 85.25754
set object 14 polygon from \
0.0,2.0,0.0 to \
0.0,0.0,3.0 to \
0.0,2.0,3.0 to \
0.0,2.0,0.0
set object 14 fill solid 0.9 border lw 2 fc palette cb 85.25754
python poly.py > poly_sorted.dat
set object 1 polygon from \
4.0,0.0,0.0 to \
4.0,2.0,0.0 to \
4.0,2.0,3.0 to \
4.0,0.0,3.0 to \
4.0,0.0,0.0
set object 1 fill solid 0.9 border lw 2 fc palette cb 85.58082
set object 2 polygon from \
4.0,2.0,0.0 to \
2.0,2.0,0.0 to \
2.0,2.0,3.0 to \
3.0,2.0,3.5 to \
4.0,2.0,3.0 to \
4.0,2.0,0.0
set object 2 fill solid 0.9 border lw 2 fc palette cb 55.88219
set object 3 polygon from \
2.0,2.0,0.0 to \
2.0,0.0,0.0 to \
2.0,0.0,3.0 to \
2.0,2.0,0.0
set object 3 fill solid 0.9 border lw 2 fc palette cb 85.25754
set object 4 polygon from \
2.0,2.0,0.0 to \
2.0,0.0,3.0 to \
2.0,2.0,3.0 to \
2.0,2.0,0.0
set object 4 fill solid 0.9 border lw 2 fc palette cb 85.25754
set object 5 polygon from \
2.0,0.0,0.0 to \
2.0,2.0,0.0 to \
2.0,2.0,3.0 to \
2.0,0.0,3.0 to \
2.0,0.0,0.0
set object 5 fill solid 0.9 border lw 2 fc palette cb 85.58082
set object 6 polygon from \
2.0,2.0,0.0 to \
0.0,2.0,0.0 to \
0.0,2.0,3.0 to \
1.0,2.0,3.5 to \
2.0,2.0,3.0 to \
2.0,2.0,0.0
set object 6 fill solid 0.9 border lw 2 fc palette cb 55.88219
set object 7 polygon from \
2.0,0.0,0.0 to \
4.0,0.0,0.0 to \
4.0,0.0,3.0 to \
3.0,0.0,3.5 to \
2.0,0.0,3.0 to \
2.0,0.0,0.0
set object 7 fill solid 0.9 border lw 2 fc palette cb 100.545204
set object 8 polygon from \
0.0,2.0,0.0 to \
0.0,0.0,0.0 to \
0.0,0.0,3.0 to \
0.0,2.0,0.0
set object 8 fill solid 0.9 border lw 2 fc palette cb 85.25754
set object 9 polygon from \
4.0,0.0,3.0 to \
4.0,2.0,3.0 to \
3.0,2.0,3.5 to \
3.0,0.0,3.5 to \
4.0,0.0,3.0
set object 9 fill solid 0.9 border lw 2 fc palette cb 128.62192
set object 10 polygon from \
0.0,2.0,0.0 to \
0.0,0.0,3.0 to \
0.0,2.0,3.0 to \
0.0,2.0,0.0
set object 10 fill solid 0.9 border lw 2 fc palette cb 85.25754
set object 11 polygon from \
0.0,0.0,0.0 to \
2.0,0.0,0.0 to \
2.0,0.0,3.0 to \
1.0,0.0,3.5 to \
0.0,0.0,3.0 to \
0.0,0.0,0.0
set object 11 fill solid 0.9 border lw 2 fc palette cb 100.545204
set object 12 polygon from \
2.0,0.0,3.0 to \
3.0,0.0,3.5 to \
3.0,2.0,3.5 to \
2.0,2.0,3.0 to \
2.0,0.0,3.0
set object 12 fill solid 0.9 border lw 2 fc palette cb 128.1315
set object 13 polygon from \
2.0,0.0,3.0 to \
2.0,2.0,3.0 to \
1.0,2.0,3.5 to \
1.0,0.0,3.5 to \
2.0,0.0,3.0
set object 13 fill solid 0.9 border lw 2 fc palette cb 128.62192
set object 14 polygon from \
0.0,0.0,3.0 to \
1.0,0.0,3.5 to \
1.0,2.0,3.5 to \
0.0,2.0,3.0 to \
0.0,0.0,3.0
set object 14 fill solid 0.9 border lw 2 fc palette cb 128.1315
关于3d - Gnuplot:尊重 Gnuplot 3d 多边形的深度顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40508404/
我在 R Markdown 文档中设置全局选项时遇到问题。下面是一个简单的例子。在这种情况下,我试图设置 global.par = TRUE .期望是任何 par()我在一个夹头中制作的规范被带到后续
Cloudflare 正在缓存我的请求,但它忽略了语言 header 。 示例请求: URL : https://api.example.com/v1/places/?param=1¶m=2
我正在尝试创建一个分面条形图,每个分面的百分比加起来为 100。对此的解决方案似乎是 group 的组合和 ..density.. .如何 - 在我看来 group与 fill 冲突. 数据: tes
我正在开发一个 C# 应用程序,该应用程序试图遵守其运行系统的时间格式。如果 Windows 控制面板更改为 24 小时格式,这就是应用程序显示时间的格式。无论如何,它成功地做到了这一点,除了只有在应
我用过 Vundle安装 editorconfig-vim插件。它正确加载并列在 :scriptnames 中.但是当我创建一个新文件时,比如 x.js ,缩进设置不是从 ~/.editorconfi
我曾尝试使用不同的方法自行解决这个问题,但没有一个给我预期的结果。 当我在我的项目的数据库中保存一个文本类型的变量时,问题就出现了。它用换行符保存它,事实上,当我尝试从我的一个 View 中编辑它时,
让我头疼的代码是这样的: $('#timeline .selected').removeClass('selected'); 它在 IE8 中无法正常运行。这些类确实被正确删除,但不知何故该元素仍然具
在处理 java 中的 Swing 对象(还有 JFX,但我稍后会担心这个问题)时,我遇到了一个让我摸不着头脑的问题。 这是我用来在程序中打开字体的代码。这是相当标准的。 public static
我正在为电子商务购物车使用 SOAP API,但我似乎无法让 session 在不同的页面中持续存在。 作为示例,我在下面有一些测试代码(带有一堆调试消息),它将一个项目添加到购物车,然后查看购物车。
我有一个 fieldset与 legend可能加载了很长的字符串。 我想要 legend尊重 fieldset 的宽度并且只使用了 50% 的空间。 目前,如果legend太长它仍然只占fieldse
我有一个完整城市的 3D 模型,想展示一个 这些建筑物的等距 View 。我为此使用 gnuplot 多边形, 因为我不认为我可以将 pm3d 用于具有坐标的多边形 不在一个明确定义的网格上。多边形以
我理解 Clojure 的 *assert*变量可用于关闭断言,但我所做的一切似乎都不起作用。 (defn foo [a] {:pre [(pos? a)]} (assert (even? a
我有一个带有 DependencyProperty 和 CoerceValueCallback 的控件。此属性绑定(bind)到模型对象上的属性。 当将控件属性设置为导致强制的值时,绑定(bind)会
可以通过将它们放置在 smcs.rsp 中来创建全局定义,当您点击播放时 - 您会注意到代码的这些部分被点击,并且一切都表现得好像它应该的那样。 但是,在 MonoDevelop 中编辑源代码时,它无
总的来说,我非常努力尊重模块的隐私(如果变量以下划线为前缀,我不会使用它)。然而,我有一个极端的情况,它看起来相当“安全”。 这是演示 ( my previous question ) parser=
我有一个悬停动画的 div(我正在使用 jquery 的 .hover() 方法)。 div 包含一个带有选择的表单。打开选择并悬停在选项上会使 IE9 将其解释为“取消悬停”父 div,导致第二个悬
如果 max_user_connections 连接已打开,是否有方法告诉 Entity Framework 等待? 我想我可以捕获异常并重试或保留一个计数器,但这最多感觉很糟糕。 我的 Azure
在我的测试中,BitmapFactory.decodeFile() 创建的 Bitmap 不遵循 EXIF header 。 例如,当我调用 Bitmap.getWidth() 时,设备拍摄的肖像图像
请帮助我了解如何解决这个问题。 这是我的路由文件 (auth-routes.js) const userControllers = require('../controllers/user') mod
我的应用程序有时会注入(inject) 标记到网站中,然后创建一个新的 带有亲戚的标签 src 例如设置并注入(inject) 导致浏览器从 http://localhost:8080/chapter
我是一名优秀的程序员,十分优秀!