找回密码
 快速注册
搜索
楼主: abababa

学习Asymptote时的一些问题

[复制链接]

413

主题

1558

回帖

1万

积分

积分
11498

显示全部楼层

 楼主| abababa 发表于 2023-4-4 18:35
hejoseph 发表于 2023-4-4 17:36
我这里没问题,不知道你那里什么问题。ASY嵌入文档的应该是my-1_0.pdf这个文件吧。
如果你只是插图完全可 ...


下面的代码my.tex:
  1. \documentclass[12pt]{article}
  2. \usepackage{amsmath,bm,yhmath,amssymb,etoolbox,esvect,stmaryrd,cite,enumitem,extarrows,mathtools,ifthen}
  3. \usepackage[amsmath, thmmarks]{ntheorem}
  4. {
  5.         \theoremstyle{nonumberplain}
  6.         \theoremheaderfont{\indent\bfseries}
  7.         \theorembodyfont{\normalfont}
  8.         \theoremsymbol{\ensuremath{\Box}}
  9.         \newtheorem{proof}{证明}
  10. }
  11. \usepackage{pgf,tikz}
  12. \usepackage[inline]{asymptote}
  13. \usepackage{float}
  14. \usepackage{pgfplots,wrapfig}
  15. \usepackage{graphicx}
  16. \usepackage{subfigure}
  17. \usepackage{tkz-euclide}
  18. \usetikzlibrary{arrows,automata,positioning,matrix,calc,intersections,shapes.geometric}
  19. \begin{document}
  20. \begin{asy}
  21. settings.outformat = "pdf";
  22. settings.prc = false;
  23. size(5cm,0);
  24. import three;
  25. draw(unitsphere);
  26. //axes3("$x$","$y$","$z$",Arrow3);
  27. \end{asy}
  28. try.
  29. \end{document}
复制代码


我先xelatex my.tex,出现一个警告:
  1. Package asymptote Warning: file `my-1.tex' not found on input line 31.
复制代码


我觉得是还没编译asy文件的原因。之后用asy *.asy,出现下面的错误:
  1. shipout3(prefix,f,preview ? nativeformat() : format,
复制代码


这个错误之前一直存在,我以为升级版本就好了,但并没有。按照39楼链接里的说明,把settings.outformat = "pdf";里的pdf改成html,这时重复上面的编译,asy *.asy之后,出现了一个my-1.html,这个网页文件里就有那个图。这时再用xelatex my.tex,期望是把那个图弄进my.pdf里,但是出现警告:
  1. Package asymptote Warning: file `my-1.tex' not found on input line 31
复制代码


图也没有进到my.pdf里。

而之前的平面图,我没有设置outformat,它就是在当前文件夹里生成了一堆图片的pdf,最后进到总的my.pdf里。

我想既然学了这个能画立体图的asymptote,就试着画几个简单的。

点评

outputformat不是pdf无法嵌入文档的,检查下你的路径设置有没有设置对,另外看看temp那个目录是否有中文字符。  发表于 2023-4-6 10:20

413

主题

1558

回帖

1万

积分

积分
11498

显示全部楼层

 楼主| abababa 发表于 2023-4-4 20:50
abababa 发表于 2023-4-4 18:35
下面的代码my.tex:


发现加上这一句settings.render=0;就好了,也不用什么outformat之类的,新的代码如下:
  1. \begin{asy}
  2. settings.render=0;
  3. import three;
  4. import graph3;
  5. size(5cm,0);
  6. draw(unitsphere);
  7. \end{asy}
复制代码


虽然画出来的那个球是全黑的,可能还是有问题,但我感觉单纯地画线应该没问题了。

点评

render=0会出现问题的,3D图形没法消隐,出来的图可能问题很大,特别是面交错的图形。  发表于 2023-4-6 10:19

413

主题

1558

回帖

1万

积分

积分
11498

显示全部楼层

 楼主| abababa 发表于 2023-4-5 19:25
对于3D的,过一点作一条直线的垂线,垂足要怎么画?例如:
  1. \begin{asy}
  2. settings.render=0;
  3. import three;
  4. import graph3;
  5. size(5cm,0);
  6. triple A1 = (1,sqrt(1/3),sqrt(8/3)), A3 = (2,0,0), A4 = (1,sqrt(3),0);
  7. \end{asy}
复制代码


想画过A1垂直于A3A4的直线的垂足。

我查了three.asy,有几个project的,弄出来都不是。

点评

这种我一般用自己写的函数直接调用就得了  发表于 2023-4-6 10:32

68

主题

434

回帖

4269

积分

积分
4269

显示全部楼层

hejoseph 发表于 2023-4-6 14:14
关于render=0的问题,你可以试试运行下这个asy代码:
size(200);
import graph3;
real C0=(1+sqrt(5))/4;
real C1=(1+sqrt(5))/2;
real C2=(5+sqrt(5))/4;
real C3=(2+sqrt(5))/2;
real C4=3*(1+sqrt(5))/4;
triple[] V={(0.5,0.0,C4),(0.5,0.0,-C4),(-0.5,0.0,C4),(-0.5,0.0,-C4),(C4,0.5,0.0),(C4,-0.5,0.0),(-C4,0.5,0.0),(-C4,-0.5,0.0),(0.0,C4,0.5),(0.0,C4,-0.5),(0.0,-C4,0.5),(0.0,-C4,-0.5),(1.0,C0,C3),(1.0,C0,-C3),(1.0,-C0,C3),(1.0,-C0,-C3),(-1.0,C0,C3),(-1.0,C0,-C3),(-1.0,-C0,C3),(-1.0,-C0,-C3),(C3,1.0,C0),(C3,1.0,-C0),(C3,-1.0,C0),(C3,-1.0,-C0),(-C3,1.0,C0),(-C3,1.0,-C0),(-C3,-1.0,C0),(-C3,-1.0,-C0),(C0,C3,1.0),(C0,C3,-1.0),(C0,-C3,1.0),(C0,-C3,-1.0),(-C0,C3,1.0),(-C0,C3,-1.0),(-C0,-C3,1.0),(-C0,-C3,-1.0),(0.5,C1,C2),(0.5,C1,-C2),(0.5,-C1,C2),(0.5,-C1,-C2),(-0.5,C1,C2),(-0.5,C1,-C2),(-0.5,-C1,C2),(-0.5,-C1,-C2),(C2,0.5,C1),(C2,0.5,-C1),(C2,-0.5,C1),(C2,-0.5,-C1),(-C2,0.5,C1),(-C2,0.5,-C1),(-C2,-0.5,C1),(-C2,-0.5,-C1),(C1,C2,0.5),(C1,C2,-0.5),(C1,-C2,0.5),(C1,-C2,-0.5),(-C1,C2,0.5),(-C1,C2,-0.5),(-C1,-C2,0.5),(-C1,-C2,-0.5)};
draw(V[0]--V[2],black);
draw(V[0]--V[12],black);
draw(V[0]--V[14],black);
draw(V[1]--V[3],black);
draw(V[1]--V[13],black);
draw(V[1]--V[15],black);
draw(V[2]--V[16],black);
draw(V[2]--V[18],black);
draw(V[3]--V[17],black);
draw(V[3]--V[19],black);
draw(V[4]--V[5],black);
draw(V[4]--V[20],black);
draw(V[4]--V[21],black);
draw(V[5]--V[22],black);
draw(V[5]--V[23],black);
draw(V[6]--V[7],black);
draw(V[6]--V[24],black);
draw(V[6]--V[25],black);
draw(V[7]--V[26],black);
draw(V[7]--V[27],black);
draw(V[8]--V[9],black);
draw(V[8]--V[28],black);
draw(V[8]--V[32],black);
draw(V[9]--V[29],black);
draw(V[9]--V[33],black);
draw(V[10]--V[11],black);
draw(V[10]--V[30],black);
draw(V[10]--V[34],black);
draw(V[11]--V[31],black);
draw(V[11]--V[35],black);
draw(V[12]--V[36],black);
draw(V[12]--V[44],black);
draw(V[13]--V[37],black);
draw(V[13]--V[45],black);
draw(V[14]--V[38],black);
draw(V[14]--V[46],black);
draw(V[15]--V[39],black);
draw(V[15]--V[47],black);
draw(V[16]--V[40],black);
draw(V[16]--V[48],black);
draw(V[17]--V[41],black);
draw(V[17]--V[49],black);
draw(V[18]--V[42],black);
draw(V[18]--V[50],black);
draw(V[19]--V[43],black);
draw(V[19]--V[51],black);
draw(V[20]--V[44],black);
draw(V[20]--V[52],black);
draw(V[21]--V[45],black);
draw(V[21]--V[53],black);
draw(V[22]--V[46],black);
draw(V[22]--V[54],black);
draw(V[23]--V[47],black);
draw(V[23]--V[55],black);
draw(V[24]--V[48],black);
draw(V[24]--V[56],black);
draw(V[25]--V[49],black);
draw(V[25]--V[57],black);
draw(V[26]--V[50],black);
draw(V[26]--V[58],black);
draw(V[27]--V[51],black);
draw(V[27]--V[59],black);
draw(V[28]--V[36],black);
draw(V[28]--V[52],black);
draw(V[29]--V[37],black);
draw(V[29]--V[53],black);
draw(V[30]--V[38],black);
draw(V[30]--V[54],black);
draw(V[31]--V[39],black);
draw(V[31]--V[55],black);
draw(V[32]--V[40],black);
draw(V[32]--V[56],black);
draw(V[33]--V[41],black);
draw(V[33]--V[57],black);
draw(V[34]--V[42],black);
draw(V[34]--V[58],black);
draw(V[35]--V[43],black);
draw(V[35]--V[59],black);
draw(V[36]--V[40],black);
draw(V[37]--V[41],black);
draw(V[38]--V[42],black);
draw(V[39]--V[43],black);
draw(V[44]--V[46],black);
draw(V[45]--V[47],black);
draw(V[48]--V[50],black);
draw(V[49]--V[51],black);
draw(V[52]--V[53],black);
draw(V[54]--V[55],black);
draw(V[56]--V[57],black);
draw(V[58]--V[59],black);
draw(surface(V[0]--V[14]--V[46]--V[44]--V[12]--cycle),blue);
draw(surface(V[1]--V[13]--V[45]--V[47]--V[15]--cycle),blue);
draw(surface(V[2]--V[16]--V[48]--V[50]--V[18]--cycle),blue);
draw(surface(V[3]--V[19]--V[51]--V[49]--V[17]--cycle),blue);
draw(surface(V[4]--V[21]--V[53]--V[52]--V[20]--cycle),blue);
draw(surface(V[5]--V[22]--V[54]--V[55]--V[23]--cycle),blue);
draw(surface(V[6]--V[24]--V[56]--V[57]--V[25]--cycle),blue);
draw(surface(V[7]--V[27]--V[59]--V[58]--V[26]--cycle),blue);
draw(surface(V[8]--V[32]--V[40]--V[36]--V[28]--cycle),blue);
draw(surface(V[9]--V[29]--V[37]--V[41]--V[33]--cycle),blue);
draw(surface(V[10]--V[30]--V[38]--V[42]--V[34]--cycle),blue);
draw(surface(V[11]--V[35]--V[43]--V[39]--V[31]--cycle),blue);
draw(surface(V[0]--V[2]--V[18]--V[42]--V[38]--V[14]--cycle),lightred);
draw(surface(V[0]--V[12]--V[36]--V[40]--V[16]--V[2]--cycle),lightred);
draw(surface(V[1]--V[3]--V[17]--V[41]--V[37]--V[13]--cycle),lightred);
draw(surface(V[1]--V[15]--V[39]--V[43]--V[19]--V[3]--cycle),lightred);
draw(surface(V[20]--V[44]--V[46]--V[22]--V[5]--V[4]--cycle),lightred);
draw(surface(V[20]--V[52]--V[28]--V[36]--V[12]--V[44]--cycle),lightred);
draw(surface(V[23]--V[47]--V[45]--V[21]--V[4]--V[5]--cycle),lightred);
draw(surface(V[23]--V[55]--V[31]--V[39]--V[15]--V[47]--cycle),lightred);
draw(surface(V[24]--V[48]--V[16]--V[40]--V[32]--V[56]--cycle),lightred);
draw(surface(V[24]--V[6]--V[7]--V[26]--V[50]--V[48]--cycle),lightred);
draw(surface(V[27]--V[51]--V[19]--V[43]--V[35]--V[59]--cycle),lightred);
draw(surface(V[27]--V[7]--V[6]--V[25]--V[49]--V[51]--cycle),lightred);
draw(surface(V[29]--V[53]--V[21]--V[45]--V[13]--V[37]--cycle),lightred);
draw(surface(V[29]--V[9]--V[8]--V[28]--V[52]--V[53]--cycle),lightred);
draw(surface(V[30]--V[54]--V[22]--V[46]--V[14]--V[38]--cycle),lightred);
draw(surface(V[30]--V[10]--V[11]--V[31]--V[55]--V[54]--cycle),lightred);
draw(surface(V[33]--V[57]--V[56]--V[32]--V[8]--V[9]--cycle),lightred);
draw(surface(V[33]--V[41]--V[17]--V[49]--V[25]--V[57]--cycle),lightred);
draw(surface(V[34]--V[58]--V[59]--V[35]--V[11]--V[10]--cycle),lightred);
draw(surface(V[34]--V[42]--V[18]--V[50]--V[26]--V[58]--cycle),lightred);

size(200);
import graph3;
real C0=(1+sqrt(5))/4;
real C1=(1+sqrt(5))/2;
real C2=(5+sqrt(5))/4;
real C3=(2+sqrt(5))/2;
real C4=3*(1+sqrt(5))/4;
triple[] V={(0.5,0.0,C4),(0.5,0.0,-C4),(-0.5,0.0,C4),(-0.5,0.0,-C4),(C4,0.5,0.0),(C4,-0.5,0.0),(-C4,0.5,0.0),(-C4,-0.5,0.0),(0.0,C4,0.5),(0.0,C4,-0.5),(0.0,-C4,0.5),(0.0,-C4,-0.5),(1.0,C0,C3),(1.0,C0,-C3),(1.0,-C0,C3),(1.0,-C0,-C3),(-1.0,C0,C3),(-1.0,C0,-C3),(-1.0,-C0,C3),(-1.0,-C0,-C3),(C3,1.0,C0),(C3,1.0,-C0),(C3,-1.0,C0),(C3,-1.0,-C0),(-C3,1.0,C0),(-C3,1.0,-C0),(-C3,-1.0,C0),(-C3,-1.0,-C0),(C0,C3,1.0),(C0,C3,-1.0),(C0,-C3,1.0),(C0,-C3,-1.0),(-C0,C3,1.0),(-C0,C3,-1.0),(-C0,-C3,1.0),(-C0,-C3,-1.0),(0.5,C1,C2),(0.5,C1,-C2),(0.5,-C1,C2),(0.5,-C1,-C2),(-0.5,C1,C2),(-0.5,C1,-C2),(-0.5,-C1,C2),(-0.5,-C1,-C2),(C2,0.5,C1),(C2,0.5,-C1),(C2,-0.5,C1),(C2,-0.5,-C1),(-C2,0.5,C1),(-C2,0.5,-C1),(-C2,-0.5,C1),(-C2,-0.5,-C1),(C1,C2,0.5),(C1,C2,-0.5),(C1,-C2,0.5),(C1,-C2,-0.5),(-C1,C2,0.5),(-C1,C2,-0.5),(-C1,-C2,0.5),(-C1,-C2,-0.5)};
draw(V[0]--V[2],black);
draw(V[0]--V[12],black);
draw(V[0]--V[14],black);
draw(V[1]--V[3],black);
draw(V[1]--V[13],black);
draw(V[1]--V[15],black);
draw(V[2]--V[16],black);
draw(V[2]--V[18],black);
draw(V[3]--V[17],black);
draw(V[3]--V[19],black);
draw(V[4]--V[5],black);
draw(V[4]--V[20],black);
draw(V[4]--V[21],black);
draw(V[5]--V[22],black);
draw(V[5]--V[23],black);
draw(V[6]--V[7],black);
draw(V[6]--V[24],black);
draw(V[6]--V[25],black);
draw(V[7]--V[26],black);
draw(V[7]--V[27],black);
draw(V[8]--V[9],black);
draw(V[8]--V[28],black);
draw(V[8]--V[32],black);
draw(V[9]--V[29],black);
draw(V[9]--V[33],black);
draw(V[10]--V[11],black);
draw(V[10]--V[30],black);
draw(V[10]--V[34],black);
draw(V[11]--V[31],black);
draw(V[11]--V[35],black);
draw(V[12]--V[36],black);
draw(V[12]--V[44],black);
draw(V[13]--V[37],black);
draw(V[13]--V[45],black);
draw(V[14]--V[38],black);
draw(V[14]--V[46],black);
draw(V[15]--V[39],black);
draw(V[15]--V[47],black);
draw(V[16]--V[40],black);
draw(V[16]--V[48],black);
draw(V[17]--V[41],black);
draw(V[17]--V[49],black);
draw(V[18]--V[42],black);
draw(V[18]--V[50],black);
draw(V[19]--V[43],black);
draw(V[19]--V[51],black);
draw(V[20]--V[44],black);
draw(V[20]--V[52],black);
draw(V[21]--V[45],black);
draw(V[21]--V[53],black);
draw(V[22]--V[46],black);
draw(V[22]--V[54],black);
draw(V[23]--V[47],black);
draw(V[23]--V[55],black);
draw(V[24]--V[48],black);
draw(V[24]--V[56],black);
draw(V[25]--V[49],black);
draw(V[25]--V[57],black);
draw(V[26]--V[50],black);
draw(V[26]--V[58],black);
draw(V[27]--V[51],black);
draw(V[27]--V[59],black);
draw(V[28]--V[36],black);
draw(V[28]--V[52],black);
draw(V[29]--V[37],black);
draw(V[29]--V[53],black);
draw(V[30]--V[38],black);
draw(V[30]--V[54],black);
draw(V[31]--V[39],black);
draw(V[31]--V[55],black);
draw(V[32]--V[40],black);
draw(V[32]--V[56],black);
draw(V[33]--V[41],black);
draw(V[33]--V[57],black);
draw(V[34]--V[42],black);
draw(V[34]--V[58],black);
draw(V[35]--V[43],black);
draw(V[35]--V[59],black);
draw(V[36]--V[40],black);
draw(V[37]--V[41],black);
draw(V[38]--V[42],black);
draw(V[39]--V[43],black);
draw(V[44]--V[46],black);
draw(V[45]--V[47],black);
draw(V[48]--V[50],black);
draw(V[49]--V[51],black);
draw(V[52]--V[53],black);
draw(V[54]--V[55],black);
draw(V[56]--V[57],black);
draw(V[58]--V[59],black);
draw(surface(V[0]--V[14]--V[46]--V[44]--V[12]--cycle),blue);
draw(surface(V[1]--V[13]--V[45]--V[47]--V[15]--cycle),blue);
draw(surface(V[2]--V[16]--V[48]--V[50]--V[18]--cycle),blue);
draw(surface(V[3]--V[19]--V[51]--V[49]--V[17]--cycle),blue);
draw(surface(V[4]--V[21]--V[53]--V[52]--V[20]--cycle),blue);
draw(surface(V[5]--V[22]--V[54]--V[55]--V[23]--cycle),blue);
draw(surface(V[6]--V[24]--V[56]--V[57]--V[25]--cycle),blue);
draw(surface(V[7]--V[27]--V[59]--V[58]--V[26]--cycle),blue);
draw(surface(V[8]--V[32]--V[40]--V[36]--V[28]--cycle),blue);
draw(surface(V[9]--V[29]--V[37]--V[41]--V[33]--cycle),blue);
draw(surface(V[10]--V[30]--V[38]--V[42]--V[34]--cycle),blue);
draw(surface(V[11]--V[35]--V[43]--V[39]--V[31]--cycle),blue);
draw(surface(V[0]--V[2]--V[18]--V[42]--V[38]--V[14]--cycle),lightred);
draw(surface(V[0]--V[12]--V[36]--V[40]--V[16]--V[2]--cycle),lightred);
draw(surface(V[1]--V[3]--V[17]--V[41]--V[37]--V[13]--cycle),lightred);
draw(surface(V[1]--V[15]--V[39]--V[43]--V[19]--V[3]--cycle),lightred);
draw(surface(V[20]--V[44]--V[46]--V[22]--V[5]--V[4]--cycle),lightred);
draw(surface(V[20]--V[52]--V[28]--V[36]--V[12]--V[44]--cycle),lightred);
draw(surface(V[23]--V[47]--V[45]--V[21]--V[4]--V[5]--cycle),lightred);
draw(surface(V[23]--V[55]--V[31]--V[39]--V[15]--V[47]--cycle),lightred);
draw(surface(V[24]--V[48]--V[16]--V[40]--V[32]--V[56]--cycle),lightred);
draw(surface(V[24]--V[6]--V[7]--V[26]--V[50]--V[48]--cycle),lightred);
draw(surface(V[27]--V[51]--V[19]--V[43]--V[35]--V[59]--cycle),lightred);
draw(surface(V[27]--V[7]--V[6]--V[25]--V[49]--V[51]--cycle),lightred);
draw(surface(V[29]--V[53]--V[21]--V[45]--V[13]--V[37]--cycle),lightred);
draw(surface(V[29]--V[9]--V[8]--V[28]--V[52]--V[53]--cycle),lightred);
draw(surface(V[30]--V[54]--V[22]--V[46]--V[14]--V[38]--cycle),lightred);
draw(surface(V[30]--V[10]--V[11]--V[31]--V[55]--V[54]--cycle),lightred);
draw(surface(V[33]--V[57]--V[56]--V[32]--V[8]--V[9]--cycle),lightred);
draw(surface(V[33]--V[41]--V[17]--V[49]--V[25]--V[57]--cycle),lightred);
draw(surface(V[34]--V[58]--V[59]--V[35]--V[11]--V[10]--cycle),lightred);
draw(surface(V[34]--V[42]--V[18]--V[50]--V[26]--V[58]--cycle),lightred);


正常情况下应该输出下图
1.png
render=0会输出下图,这是因为没法正确消隐
2.png

413

主题

1558

回帖

1万

积分

积分
11498

显示全部楼层

 楼主| abababa 发表于 2023-4-6 15:39
hejoseph 发表于 2023-4-6 14:14
关于render=0的问题,你可以试试运行下这个asy代码:
size(200);
import graph3;

shipout3(prefix,f,preview ? nativeformat() : format,

上面这个错误,好像和显卡有关,我昨天发给网友,他那里也是这个问题,没能弄出pdf来,但生成html的那个都是好的。我搜索这个,发现还是有人遇到相同的问题:
linux.debian.bugs.dist.narkive.com/CzpDhAUs/bug-1025049-asymptote-error-in-shipout3

413

主题

1558

回帖

1万

积分

积分
11498

显示全部楼层

 楼主| abababa 发表于 2023-4-6 16:22
abababa 发表于 2023-4-5 19:25
对于3D的,过一点作一条直线的垂线,垂足要怎么画?例如:

我知道那个怎么算,但是想弄个一般的,现在点是用triple定义的,直线怎么定义不知道。
点$(x_0,y_0,z_0)$到点$(x_1,y_1,z_1), (x_2,y_2,z_2)$所成直线的垂足坐标为
\[(k(x_2-x_1)+x_1, k(y_2-y_1)+y_1, k(z_2-z_1)+z_1)\]

其中
\[k=\frac{(x_1-x_0)(x_2-x_1)+(y_1-y_0)(y_2-y_1)+(z_1-z_0)(z_2-z_1)}{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}\]

点评

空间直线一般两种表达方式:点和方向向量,两平面方程。你如果做一般的,自己做一个文件,需要的时候引入就行了。  发表于 2023-4-6 16:27

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2023-4-7 07:53
abababa 发表于 2023-3-27 11:24
这个在我这里运行,出现以下问题:
shipout3(prefix,f,preview ? nativeformat() : format,

若本机总是不行, 可以使用Asymptote Web Application [output选择pdf]
如果PDF需要嵌入PRC可以使用Asymptote server的command-line interface
  1. curl --data-binary 'import teapot;' 'asymptote.ualberta.ca:10007?f=pdf&prc' -o teapot.pdf
复制代码


ASY-Forum

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2023-4-7 16:58
本帖最后由 hbghlyj 于 2023-4-7 17:25 编辑
abababa 发表于 2023-4-3 14:27
搜索到两个类似的:


根据John Bowman用下面的命令编译
  1. ./configure --disable-gc
  2. make clean
  3. make CFLAGS=-g
复制代码

gdb --args asy 1.asy检查
  1. Starting program: /usr/local/bin/asy 1.asy
  2. [Thread debugging using libthread_db enabled]
  3. Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
  4. Program received signal SIGSEGV, Segmentation fault.
  5. 0x00005555558f2066 in GC_find_limit_with_bound (p=0x555555ac04a8 "",
  6.     up=up@entry=0, bound=bound@entry=0x0) at os_dep.c:1018
  7. 1018                    GC_noop1((word)(*result));
复制代码

用valgrind检查
  1. valgrind --track-origins=yes asy test
复制代码
输出有很多. 最后几行是
  1. ==35368==
  2. ==35368== Conditional jump or move depends on uninitialised value(s)
  3. ==35368==    at 0x49D2CA: GC_find_header (headers.c:32)
  4. ==35368==    by 0x4A186C: GC_mark_and_push_stack (mark.c:1487)
  5. ==35368==    by 0x4A1931: GC_push_all_eager (mark.c:1589)
  6. ==35368==    by 0x4AF158: GC_with_callee_saves_pushed (mach_dep.c:335)
  7. ==35368==    by 0x4A259C: GC_push_regs_and_stack (mark_rts.c:853)
  8. ==35368==    by 0x4A259C: GC_push_roots (mark_rts.c:926)
  9. ==35368==    by 0x4A0F67: GC_mark_some (mark.c:388)
  10. ==35368==    by 0x498004: GC_stopped_mark (alloc.c:880)
  11. ==35368==    by 0x498FBE: GC_try_to_collect_inner (alloc.c:626)
  12. ==35368==    by 0x499ECC: GC_collect_or_expand (alloc.c:1678)
  13. ==35368==    by 0x49A214: GC_allocobj (alloc.c:1784)
  14. ==35368==    by 0x49E09E: GC_generic_malloc_inner (malloc.c:194)
  15. ==35368==    by 0x49E2C0: GC_generic_malloc (malloc.c:254)
  16. ==35368==  Uninitialised value was created by a stack allocation
  17. ==35368==    at 0x4AF0C1: GC_with_callee_saves_pushed (mach_dep.c:229)
  18. ==35368==
  19. ==35368==
  20. ==35368== More than 100 errors detected.  Subsequent errors
  21. ==35368== will still be recorded, but in less detail than before.
  22. ==35368== Use of uninitialised value of size 8
  23. ==35368==    at 0x49D2F7: GC_find_header (headers.c:33)
  24. ==35368==    by 0x4A186C: GC_mark_and_push_stack (mark.c:1487)
  25. ==35368==    by 0x4A1931: GC_push_all_eager (mark.c:1589)
  26. ==35368==    by 0x4AF158: GC_with_callee_saves_pushed (mach_dep.c:335)
  27. ==35368==    by 0x4A259C: GC_push_regs_and_stack (mark_rts.c:853)
  28. ==35368==    by 0x4A259C: GC_push_roots (mark_rts.c:926)
  29. ==35368==    by 0x4A0F67: GC_mark_some (mark.c:388)
  30. ==35368==    by 0x498004: GC_stopped_mark (alloc.c:880)
  31. ==35368==    by 0x498FBE: GC_try_to_collect_inner (alloc.c:626)
  32. ==35368==    by 0x499ECC: GC_collect_or_expand (alloc.c:1678)
  33. ==35368==    by 0x49A214: GC_allocobj (alloc.c:1784)
  34. ==35368==    by 0x49E09E: GC_generic_malloc_inner (malloc.c:194)
  35. ==35368==    by 0x49E2C0: GC_generic_malloc (malloc.c:254)
  36. ==35368==  Uninitialised value was created by a stack allocation
  37. ==35368==    at 0x4AF0C1: GC_with_callee_saves_pushed (mach_dep.c:229)
  38. ==35368==
  39. ==35437==
  40. ==35437== HEAP SUMMARY:
  41. ==35437==     in use at exit: 3,281,028 bytes in 15,961 blocks
  42. ==35437==   total heap usage: 303,368 allocs, 287,407 frees, 78,911,078 bytes allocated
  43. ==35437==
  44. ==35437== LEAK SUMMARY:
  45. ==35437==    definitely lost: 2,725,919 bytes in 6,671 blocks
  46. ==35437==    indirectly lost: 360 bytes in 3 blocks
  47. ==35437==      possibly lost: 0 bytes in 0 blocks
  48. ==35437==    still reachable: 554,749 bytes in 9,287 blocks
  49. ==35437==         suppressed: 0 bytes in 0 blocks
  50. ==35437== Rerun with --leak-check=full to see details of leaked memory
  51. ==35437==
  52. ==35437== For lists of detected and suppressed errors, rerun with: -s
  53. ==35437== ERROR SUMMARY: 640245 errors from 101 contexts (suppressed: 0 from 0)
  54. ==35368==
  55. ==35368== HEAP SUMMARY:
  56. ==35368==     in use at exit: 1,050,411 bytes in 11,466 blocks
  57. ==35368==   total heap usage: 210,055 allocs, 198,589 frees, 8,857,023 bytes allocated
  58. ==35368==
  59. ==35368== LEAK SUMMARY:
  60. ==35368==    definitely lost: 853,760 bytes in 6,670 blocks
  61. ==35368==    indirectly lost: 0 bytes in 0 blocks
  62. ==35368==      possibly lost: 0 bytes in 0 blocks
  63. ==35368==    still reachable: 196,651 bytes in 4,796 blocks
  64. ==35368==         suppressed: 0 bytes in 0 blocks
  65. ==35368== Rerun with --leak-check=full to see details of leaked memory
  66. ==35368==
  67. ==35368== For lists of detected and suppressed errors, rerun with: -s
  68. ==35368== ERROR SUMMARY: 640245 errors from 101 contexts (suppressed: 0 from 0)
复制代码

没有懂

413

主题

1558

回帖

1万

积分

积分
11498

显示全部楼层

 楼主| abababa 发表于 2023-4-7 18:21
hbghlyj 发表于 2023-4-7 07:53
若本机总是不行, 可以使用Asymptote Web Application [output选择pdf]
如果PDF需要嵌入PRC可以使用Asympto ...

不想用那么多工具,要不是为了画圆锥曲线方便点,我就不学这个asymptote了,用tkz-euclide就很好。

点评

如果不是画3D图估计生成pdf不会有问题  发表于 2023-4-7 22:01

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2023-4-9 05:00
abababa 发表于 2023-4-6 08:39
上面这个错误,好像和显卡有关


我昨天这个问题:
sourceforge.net/p/asymptote/discussion/409349/thread/ca9f0b6278/
John Bowman told me to upgrade graphic drivers:
OpenGL GLSL version 1.40 is very old (circa 2009). For full functionality (e.g. transparency) you will need to upgrade to GLSL 4.3 or later (which dates back to 2013). You should upgrade your drivers.

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2023-4-9 21:33
本帖最后由 hbghlyj 于 2023-4-10 11:50 编辑
abababa 发表于 2023-4-6 08:39
好像和显卡有关...

编译 Vulkan 时出错
汇编消息:
  1. {standard input}: Assembler messages:
  2. {standard input}:310129: Warning: end of file not at end of a line; newline inserted
  3. {standard input}:310173: Error: unknown pseudo-op: `.lvl261'
  4. {standard input}: Error: open CFI at the end of file; missing .cfi_endproc directive
  5. cc: fatal error: Killed signal terminated program cc1
复制代码
嗯,根据 stackoverflow.com/a/25584112,看起来这可能是构建期间内存不足的情况?需要终止其他进程以释放内存。
重新编译多次,终于成功了。

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2023-4-10 18:52
abababa 发表于 2023-4-6 08:39
好像和显卡有关...

我在 Centos 8 上的错误消息是类似的。
昨天发到Asymptote Discussion
sourceforge.net/p/asymptote/discussion/409349/thread/ca9f0b6278/
John Bowman - 6 hours ago
Under your platform there is a problem with OSMesa initialization. CentOS tends to use very old software. CentOS 8.5.2111 was released sometime ago, in November 2021 and CentOS was subsequently discontinued. Try upgrading to a newer OS.
需要升级操作系统。

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2023-4-11 00:47
abababa 发表于 2023-4-6 08:39
shipout3(prefix,f,preview ? nativeformat() : format,

上面这个错误,好像和显卡有关,我昨天发给网友 ...


升级到Ubuntu 22.04.2 LTS后编译freeglut和asymptote,根据此讨论设置 gs 路径,尝试渲染3D图形,报错
    shipout3(prefix,f,preview ? nativeformat() : format,
            ^
/usr/local/share/asymptote/three.asy: 2896.13: runtime: to support onscreen OpenGL rendering; please install the glut library, then ./configure; make
因为我已经根据官方文档编译安装了freeglut 3.2.1,所以只需要安装libglm-dev
  1. apt-get install libglm-dev
复制代码
上述错误消失了。出现新错误:
freeglut (asy): failed to open display ''

Putty设置“X display location=:0”后,“xeyes”和“xclock”运行成功 Quicker_20230410_183738.png
出现新错误:
X Error of failed request:  GLXUnsupportedPrivateRequest
  Major opcode of failed request:  143 (GLX)
  Minor opcode of failed request:  17 (X_GLXVendorPrivateWithReply)
  Serial number of failed request:  24
  Current serial number in output stream:  24

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2023-4-14 02:25
本帖最后由 hbghlyj 于 2023-4-15 12:50 编辑 Floating-point unit 浮点运算器
A floating-point unit is a part of a computer system specially designed to carry out operations on floating-point numbers. Typical operations are addition, subtraction, multiplication, division, and square root.

FP exceptions GNU libc
The IEEE 754 standard defines five exceptions that can occur during a calculation. Each corresponds to a particular sort of error, such as overflow.

413

主题

1558

回帖

1万

积分

积分
11498

显示全部楼层

 楼主| abababa 发表于 2023-4-15 19:42
hbghlyj 发表于 2023-4-14 02:25
试一下
the -mask command-line option  Mask fpu exceptions

加上这个-mask,编译那个最简单的球的那个,就是draw(unitsphere);,这个出来了,而且也是有点立体感的那个球,不是像平面图那样的。其它的还不知道会不会有问题。

点评

帖内代码建议使用[inlinecode]  发表于 2023-4-15 19:54

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2023-4-15 19:46


可以试一下47# hejoseph的代码看输出是否和左图一致.
可以把-mask保存在config.asy中, 就不必每次都加-mask

413

主题

1558

回帖

1万

积分

积分
11498

显示全部楼层

 楼主| abababa 发表于 2023-4-15 20:55
hbghlyj 发表于 2023-4-15 19:46
可以试一下47# hejoseph的代码看输出是否和左图一致.
可以把-mask保存在config.asy中, 就不必每次都加-ma ...

47楼的那个,仅用import graph3;是正常的,前面加一个import three;就出问题了。

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2023-4-15 21:07
abababa 发表于 2023-4-15 13:55
47楼的那个,仅用import graph3;是正常的,前面加一个import three;就出问题了。

asymptote.ualberta.ca 仅用import graph3;import three;是正常的,一并用也正常

413

主题

1558

回帖

1万

积分

积分
11498

显示全部楼层

 楼主| abababa 发表于 2023-4-15 21:33
hbghlyj 发表于 2023-4-15 21:07
试 http://asymptote.ualberta.ca 仅用或是正常的,一并用也正常

我这里后来也没问题了,不知道怎么回事,代码我就改了这一句,但是后来手动把那些.asy,.pre等文件都删除了。

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2023-4-15 21:53
本帖最后由 hbghlyj 于 2023-4-16 13:25 编辑 Asymptote forum
Could you run without -mask in the debugger (e.g. gdb) and tell me which library call in glrender.cc the floating point exception is generating the floating point exception? Once we identify the line number we can locally apply the mask like this (there might be more than one place):
  1. fpu_trap(false); // Work around FE_INVALID
  2. // offending call goes here
  3. fpu_trap(settings::trap());
复制代码

手机版|悠闲数学娱乐论坛(第3版)

GMT+8, 2025-3-4 12:11

Powered by Discuz!

× 快速回复 返回顶部 返回列表