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

Asymptote测试

[复制链接]

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

kuing 发表于 2024-11-11 21:49

你是意思是在 /asy/ 下面再新建一个 php 文件,如 test.php,内容是 echo function_exists('curl_version'); 然后进入 /asy/test.php 看看输出啥是吗?

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

kuing 发表于 2024-11-11 21:55
kuing 发表于 2024-11-11 21:49
你是意思是在 /asy/ 下面再新建一个 php 文件,如 test.php,内容是 echo function_exists('curl_version ...

进入 kuing.cjhb.site/asy/test.php,结果是 1

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2024-11-11 21:58

curl 基础例子 ¶

只要你编译完的PHP设置了支持 cURL 扩展,你就可以开始使用cURL函数了。使用 cURL 函数的基本思想是先使用 curl_init() 初始化 cURL会话,接着可以通过 curl_setopt() 设置需要的全部选项,然后使用 curl_exec() 来执行会话,当执行完会话后使用 curl_close() 关闭会话。这是一个使用 cURL 函数获取 example.com 主页保存到文件的例子:

示例 #1 使用 PHP cURL 模块获取 example.com 的主页

<?php

$ch
= curl_init("http://www.example.com/");
$fp = fopen("example_homepage.txt", "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
if(
curl_error($ch)) {
fwrite($fp, curl_error($ch));
}
curl_close($ch);
fclose($fp);
?>

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2024-11-11 22:00


这样 cURL 确認启用了。

接下来我们检查 cURL 是否返回错误,有一个函数curl_error可以实现这个目的
curl_error — 返回当前会话最后一次错误的字符串

建议在原 php 文件中添加一个部分:
  1. curl_exec($ch);
  2. if(curl_error($ch)) {
  3.     exit(curl_error($ch));
  4. }
复制代码
这样程序就会退出并显示错误信息

点评

加在哪?  发表于 2024-11-11 22:03
curl_exec 行之后  发表于 2024-11-11 22:04

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

kuing 发表于 2024-11-11 22:06
hbghlyj 发表于 2024-11-11 22:00
这样 cURL 确認启用了。

接下来我们检查 cURL 是否返回错误,有一个函数curl_error可以实现这个目的
  1. <?php
  2. if(empty($_GET['format'])){$f='svg';}
  3. //if(empty($_GET['format'])){$f='png';}
  4. elseif($_GET['format']=='svg'||$_GET['format']=='png'||$_GET['format']=='html') {$f=$_GET['format'];}
  5. $url = "http://asymptote.ualberta.ca:10007?f=".$f;
  6. if(isset($_GET['code'])){
  7. $curl = curl_init($url);
  8. curl_setopt($curl, CURLOPT_URL, $url);
  9. curl_setopt($curl, CURLOPT_POST, true);
  10. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  11. $headers = array(
  12.    "Content-Type: text/plain",
  13. );
  14. curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  15. curl_setopt($curl, CURLOPT_POSTFIELDS, $_GET['code']);
  16. $resp = curl_exec($curl);
  17. curl_exec($ch);
  18. if(curl_error($ch)) {
  19.     exit(curl_error($ch));
  20. }
  21. curl_close($curl);
  22. if($f=='svg'){header( 'Content-type: image/svg+xml' );}
  23. if($f=='png'){header("Content-Type: image/png");}
  24. print($resp);
  25. }
  26. ?>
复制代码

这样吗?然后怎么看?

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2024-11-11 22:07
如果仍然什么也看不见,没有 curl_error 信息,则很可能上游阻止了所有 InfinityFree 发送的请求

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2024-11-11 22:08
如果cURL正常運作,我能想到的唯一可能性是服务器被上游拒绝了(如果是这种情况,唯一的解决方案就是改变上游,例如改变为 AoPS)。还有其他可能性吗?

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

kuing 发表于 2024-11-11 22:10
hbghlyj 发表于 2024-11-11 22:07
如果仍然什么也看不见,没有 curl_error 信息,则很可能上游阻止了所有 InfinityFree 发送的请求  ...

已经将 /asy/index.php 改成 47#,然后再看前面的那些图还是没显示。
如果进入 kuing.cjhb.site/asy/?format=svg&code=import%20venn%3B 会显示 Warning 啥的

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

kuing 发表于 2024-11-11 22:14
“在这里应该将 curl_error 参数更改为 $resp,以匹配上一行 curl_exec 输出变量”
你写个具体的代码好吗,我一点也不懂

点评

希望 curl_error 不是空字符串,以便我们可以根据其信息进行诊断  发表于 2024-11-11 22:30

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2024-11-11 22:23
也许可以在 InfinityFree 论坛上询问,希望他们能提供帮助

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2024-11-11 22:25
所以这意味着InfinityFree可以 cURL 获取除 Asymptote 服务器之外的任何其他网站?
或许也可以在 Asymptote 帮助论坛上询问。他们可能已经封锁了这个 IP?告诉他们这是正常的用途,而不是恶意发送的洪水请求

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

kuing 发表于 2024-11-11 22:31
已按 51# 的改了,现在进入 kuing.cjhb.site/asy/?format=svg&code=import%20venn%3B 显示 Failed to connect to asymptote.ualberta.ca port 10007 after 0 ms: Couldn't connect to server

点评

可以更改网址吗?测试是否可以获取其他网站?  发表于 2024-11-11 22:32
如果所有其他网站都可以获取,那么 InfinityFree 肯定被 Asymptote 端屏蔽了!  发表于 2024-11-11 22:33
改成什么?  发表于 2024-11-11 22:33
更改为其他网站,例如 example.com  发表于 2024-11-11 22:35

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

kuing 发表于 2024-11-11 22:35
更改网址是指将代码里的
  1. $url = "http://asymptote.ualberta.ca:10007?f=".$f;
复制代码
改成别的网站吗?

点评

是的  发表于 2024-11-11 22:35
您是否看到相同的 curl_error 信息?  发表于 2024-11-11 22:36
如果只有 Asymptote 阻止了 InfinityFree,那么在获取其他网站时就不会看到相同的 curl_error 信息  发表于 2024-11-11 22:37
那就改成 $url = "http://example.com"; 吗?  发表于 2024-11-11 22:38
是否发生同样的错误  发表于 2024-11-11 22:38
可以更改为专门的测试服务器“https://httpbin.org/post”  发表于 2024-11-11 22:40

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

kuing 发表于 2024-11-11 22:39
改成 $url = "http://example.com"; 后,现在 53# 的链接点击后显示 This XML file does not appear to have any style information associated with it. The document tree is shown below.

点评

因此 cURL 连接成功  发表于 2024-11-11 22:40
可以测试“https://httpbin.org/post”  发表于 2024-11-11 22:41
所以现在我们知道只有 Asymptote 服务器阻止了 InfinityFree 服务器。  发表于 2024-11-11 22:41
我们可以改用AoPS  发表于 2024-11-11 22:42
或者我们向 Asymptote 帮助台询问?  发表于 2024-11-11 22:42
也许 Asymptote 服务器阻止了特定的 IP 地址  发表于 2024-11-11 22:43
测试那网扯啥意思?改成 $url = "https://httpbin.org/post"; 吗?  发表于 2024-11-11 22:43
是的。此特定测试服务器返回 POST 内容  发表于 2024-11-11 22:45
如果正常,应该可以看到所發送的内容  发表于 2024-11-11 22:45

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

kuing 发表于 2024-11-11 22:47
改成 $url = "https://httpbin.org/post"; 后,现在 53# 的链接点击后显示红底黑字的
This page contains the following errors:
error on line 1 at column 1: Document is empty
Below is a rendering of the page up to the first error.

点评

因此 cURL 连接成功  发表于 2024-11-11 22:49
所以现在最有可能是因为 Asymptote 服务器阻止了特定的 IP 地址  发表于 2024-11-11 22:51

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

kuing 发表于 2024-11-11 22:53
或许我们这边有时连接 Asymptote 太频繁,触发了那边的防御机制?
比如说浏览本帖第一页,就同时有很多个 asy 图

这次不显示是从几天前开始的,前几天你有没有哪个帖子很多 asy 图?

点评

我们现在能做什么🤔  发表于 2024-11-11 22:59
是否可以改为使用 AoPS ?  发表于 2024-11-11 22:59
AoPS 也以 PNG 格式渲染 Asymptote  发表于 2024-11-11 23:00
我又不会写代码,怎么换 aops 啊  发表于 2024-11-11 23:01
可以更改 IP 吗?比如使用其他服务器  发表于 2024-11-11 23:01

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

kuing 发表于 2024-11-11 23:04
我困了,你研究下怎么改成 aops ,明天说吧

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2024-11-11 23:09

AoPS TeXer (Asymptote替代方案)

kuing 发表于 2024-11-11 15:04
我困了,你研究下怎么改成 aops ,明天说吧


作為 asymptote.ualberta.ca/ 的替代品,
AoPS TeXer 支持 Asymptote 的服务器端渲染
artofproblemsolving.com/texer
它多年来一直为 AoPS 社区和 AoPS wiki 提供公式,因此是可靠的。
1000001014.png

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2024-11-11 23:13
kuing 发表于 2024-11-11 15:04
我困了,你研究下怎么改成 aops ,明天说吧



测试一下php脚本,从aops texer把tex转换成png再重定向.
用法:首先将需要的公式转成base64,比如
  1. window.btoa("$x^2+y^2$")
  2. 输出:JHheMit5XjIk
复制代码
所以$x^2+y^2$的base64是JHheMit5XjIk.然后把图片地址填上
  1. /aops.php?tex=JHheMit5XjIk
复制代码
即可.
重定向以后得到的图片是(每次生成新的链接)

我们可以封装一个简单的js函数
  1. function aops(str){window.open("/aops.php?tex="+window.btoa(str.replaceAll('\n','')))}
复制代码

示例1:将一段公式经过Base64加密得到的,可以在浏览器调试工具中运行,注意,反斜杠需要转义(当然也可以从html元素中读取,就不用手动转义了):
  1. aops('$$\\sqrt x=\\frac{\\sqrt y}{\\sqrt z}$$')
复制代码

重定向以后得到的图片是

示例2:将一段Asymptote代码去掉换行符以后经过Base64加密得到的,可以在浏览器调试工具中运行:
  1. aops(`[asy]import graph;
  2. import palette;
  3. import contour;
  4. size(12cm,IgnoreAspect);
  5. pair a=(pi/2,0);
  6. pair b=(3pi/2,2pi);
  7. real f(real x, real y) {return cos(x)*sin(y);}
  8. int N=100;
  9. int Divs=10;
  10. defaultpen(1bp);
  11. bounds range=bounds(-1,1);
  12. real[] Cvals=uniform(range.min,range.max,Divs);
  13. guide[][] g=contour(f,a,b,Cvals,N,operator --);
  14. pen[] Palette=quantize(Rainbow(),Divs);
  15. pen[][] interior=interior(g,extend(Palette,grey,black));
  16. fill(g,interior);
  17. draw(g);
  18. palette("$f(x,y)$",range,point(SE)+(0.5,0),point(NE)+(1,0),Right,Palette,
  19.         PaletteTicks("$%+#0.1f$",N=Divs));[/asy]`)
复制代码

其中的asy标签是aops论坛自定义的.重定向以后得到的图片是

更多的Asymptote示例(均来自官网)
  1. aops(`[asy]import graph;
  2. size(140mm,70mm,IgnoreAspect);
  3. scale(false);
  4. real[] x={1,3,4,5,6};
  5. real[] y={1,5,2,0,4};
  6. marker mark=marker(scale(1mm)*cross(6,false,r=0.35),red,Fill);
  7. draw(graph(x,y,Hermite),"Hermite Spline",mark);
  8. xaxis("$x$",Bottom,LeftTicks(x));
  9. yaxis("$y$",Left,LeftTicks);
  10. attach(legend(),point(NW),40S+30E,UnFill);
  11. [/asy]`)
复制代码


  1. aops(`[asy]import graph;
  2. size(200,IgnoreAspect);
  3. real f(real x) {return 1/x;};
  4. bool3 branch(real x)
  5. {
  6.   static int lastsign=0;
  7.   if(x == 0) return false;
  8.   int sign=sgn(x);
  9.   bool b=lastsign == 0 || sign == lastsign;
  10.   lastsign=sign;
  11.   return b ? true : default;
  12. }
  13. draw(graph(f,-1,1,branch));
  14. axes("$x$","$y$",red);
  15. [/asy]`)
复制代码


  1. aops(`[asy]import graph;
  2. real Freq=60.0;
  3. real margin=5mm;
  4. pair exp(pair x) {
  5.   return exp(x.x)*(cos(x.y)+I*sin(x.y));
  6. }
  7. real Merr(real x, real w) {
  8.   real tau=x/(2*Freq);
  9.   return 20*log(abs((tau*w+tau/(exp(I*2*pi*Freq*tau)-1))*(I*2*pi*Freq)));
  10. }
  11. real Aerr(real x, real w) {
  12.   real tau=x/(2*Freq);
  13.   return degrees((tau*w+tau/(exp(I*2*pi*Freq*tau)-1))*(I*2*pi*Freq));
  14. }
  15. picture pic1;
  16. scale(pic1,Log,Linear);
  17. real Merr1(real x){return Merr(x,1);}
  18. draw(pic1,graph(pic1,Merr1,1e-4,1),black+1.2);
  19. ylimits(pic1,-60,20);
  20. yaxis(pic1,"magnitude (dB)",LeftRight,RightTicks(new
  21.                                                  real[] {-60,-40,-20,0,20}));
  22. xaxis(pic1,"$f/f_\\mathrm{Ny}$",BottomTop,LeftTicks(N=5));
  23. yequals(pic1,0,Dotted);
  24. yequals(pic1,-20,Dotted);
  25. yequals(pic1,-40,Dotted);
  26. xequals(pic1,1e-3,Dotted);
  27. xequals(pic1,1e-2,Dotted);
  28. xequals(pic1,1e-1,Dotted);
  29. size(pic1,100,100,point(pic1,SW),point(pic1,NE));
  30. label(pic1,"$\\theta=1$",point(pic1,N),2N);
  31. frame f1=pic1.fit();
  32. add(f1);
  33. picture pic1p;
  34. scale(pic1p,Log,Linear);
  35. real Aerr1(real x){return Aerr(x,1);}
  36. draw(pic1p,graph(pic1p,Aerr1,1e-4,1),black+1.2);
  37. ylimits(pic1p,-5,95);
  38. yaxis(pic1p,"phase (deg)",LeftRight,RightTicks(new real[] {0,45,90}));
  39. xaxis(pic1p,"$f/f_\\mathrm{Ny}$",BottomTop,LeftTicks(N=5));
  40. yequals(pic1p,0,Dotted);
  41. yequals(pic1p,45,Dotted);
  42. yequals(pic1p,90,Dotted);
  43. xequals(pic1p,1e-3,Dotted);
  44. xequals(pic1p,1e-2,Dotted);
  45. xequals(pic1p,1e-1,Dotted);
  46. size(pic1p,100,100,point(pic1p,SW),point(pic1p,NE));
  47. frame f1p=pic1p.fit();
  48. f1p=shift(0,min(f1).y-max(f1p).y-margin)*f1p;
  49. add(f1p);
  50. picture pic2;
  51. scale(pic2,Log,Linear);
  52. real Merr2(real x){return Merr(x,0.75);}
  53. draw(pic2,graph(pic2,Merr2,1e-4,1),black+1.2);
  54. ylimits(pic2,-60,20);
  55. yaxis(pic2,"magnitude (dB)",LeftRight,RightTicks(new
  56.                                                  real[] {-60,-40,-20,0,20}));
  57. xaxis(pic2,"$f/f_\\mathrm{Ny}$",BottomTop,LeftTicks(N=5));
  58. yequals(pic2,0,Dotted);
  59. yequals(pic2,-20,Dotted);
  60. yequals(pic2,-40,Dotted);
  61. xequals(pic2,1e-3,Dotted);
  62. xequals(pic2,1e-2,Dotted);
  63. xequals(pic2,1e-1,Dotted);
  64. size(pic2,100,100,point(pic2,SW),point(pic2,NE));
  65. label(pic2,"$\\theta=0.75$",point(pic2,N),2N);
  66. frame f2=pic2.fit();
  67. f2=shift(max(f1).x-min(f2).x+margin)*f2;
  68. add(f2);
  69. picture pic2p;
  70. scale(pic2p,Log,Linear);
  71. real Aerr2(real x){return Aerr(x,0.75);}
  72. draw(pic2p,graph(pic2p,Aerr2,1e-4,1),black+1.2);
  73. ylimits(pic2p,-5,95);
  74. yaxis(pic2p,"phase (deg)",LeftRight,RightTicks(new real[] {0,45.1,90}));
  75. xaxis(pic2p,"$f/f_\\mathrm{Ny}$",BottomTop,LeftTicks(N=5));
  76. yequals(pic2p,0,Dotted);
  77. yequals(pic2p,45,Dotted);
  78. yequals(pic2p,90,Dotted);
  79. xequals(pic2p,1e-3,Dotted);
  80. xequals(pic2p,1e-2,Dotted);
  81. xequals(pic2p,1e-1,Dotted);
  82. size(pic2p,100,100,point(pic2p,SW),point(pic2p,NE));
  83. frame f2p=pic2p.fit();
  84. f2p=shift(max(f1p).x-min(f2p).x+margin,min(f2).y-max(f2p).y-margin)*f2p;
  85. add(f2p);
  86. [/asy]`)
复制代码


  1. aops(`[asy]import graph;
  2. import palette;
  3. import contour;
  4. size(10cm,10cm,IgnoreAspect);
  5. pair a=(0,0);
  6. pair b=(2pi,2pi);
  7. real f(real x, real y) {return cos(x)*sin(y);}
  8. int N=200;
  9. int Divs=10;
  10. int divs=2;
  11. defaultpen(1bp);
  12. pen Tickpen=black;
  13. pen tickpen=gray+0.5*linewidth(currentpen);
  14. pen[] Palette=BWRainbow();
  15. bounds range=image(f,Automatic,a,b,N,Palette);
  16. // Major contours
  17. real[] Cvals=uniform(range.min,range.max,Divs);
  18. draw(contour(f,a,b,Cvals,N,operator --),Tickpen);
  19. // Minor contours
  20. real[] cvals;
  21. for(int i=0; i < Cvals.length-1; ++i)
  22.   cvals.append(uniform(Cvals[i],Cvals[i+1],divs)[1:divs]);
  23. draw(contour(f,a,b,cvals,N,operator --),tickpen);
  24. xaxis("$x$",BottomTop,LeftTicks,above=true);
  25. yaxis("$y$",LeftRight,RightTicks,above=true);
  26. palette("$f(x,y)$",range,point(NW)+(0,0.5),point(NE)+(0,1),Top,Palette,
  27.         PaletteTicks(N=Divs,n=divs,Tickpen,tickpen));
  28. [/asy]`)
复制代码


  1. aops(`[asy]import graph;
  2. import stats;
  3. size(400,200,IgnoreAspect);
  4. int n=10000;
  5. real[] a=new real[n];
  6. for(int i=0; i < n; ++i) a[i]=Gaussrand();
  7. draw(graph(Gaussian,min(a),max(a)),blue);
  8. // Optionally calculate "optimal" number of bins a la Shimazaki and Shinomoto.
  9. int N=bins(a);
  10. histogram(a,min(a),max(a),N,normalize=true,low=0,lightred,black,bars=false);
  11. xaxis("$x$",BottomTop,LeftTicks);
  12. yaxis("$dP/dx$",LeftRight,RightTicks(trailingzero));[/asy]`)
复制代码


  1. aops(`[asy]import graph;
  2. size(0,100);
  3. path g=ellipse((0,0),1,2);
  4. scale(true);
  5. axis(Label("C",align=10W),g,LeftTicks(endlabel=false,8,end=false),
  6.      ticklocate(0,360,new real(real v) {
  7.          path h=(0,0)--max(abs(max(g)),abs(min(g)))*dir(v);
  8.          return intersect(g,h)[0];}));[/asy]`)
复制代码


  1. aops(`[asy]import graph;
  2. import palette;
  3. int n=256;
  4. pen[] Palette=BWRainbow();
  5. real w(real w0, real z0, real z) {return w0*sqrt(1+(z/z0)^2);}
  6. real pot(real lambda, real w0, real r, real z)
  7. {
  8.   real z0=pi*w0^2/lambda, kappa=2pi/lambda;
  9.   return exp(-2*(r/w(w0,z0,z))^2)*cos(kappa*z)^2;
  10. }
  11. picture make_field(real lambda, real w0)
  12. {
  13.   real[][] v=new real[n][n];
  14.   for(int i=0; i < n; ++i)
  15.     for(int j=0; j < n; ++j)
  16.       v[i][j]=pot(lambda,w0,i-n/2,abs(j-n/2));
  17.   picture p=new picture;
  18.   size(p,250,250,IgnoreAspect);
  19.   real xm=-n/lambda, ym=-n/(2*w0), xx=n/lambda, yx=n/(2*w0);
  20.   image(p,v,(xm,ym),(xx,yx),Palette);
  21.   xlimits(p,xm,xx);
  22.   ylimits(p,ym,yx);
  23.   xaxis(p,"{\\Large $z/\\frac{\\lambda}{2}$}",BottomTop,LeftTicks);
  24.   yaxis(p,"{\\Large $r/w_0$}",LeftRight,RightTicks);
  25.   label(p,format("{\\LARGE $w_0/\\lambda=%.2f$}",w0/lambda),point(p,NW),5N);
  26.   return p;
  27. }
  28. picture p=make_field(160,80);
  29. picture q=make_field(80,80);
  30. picture r=make_field(16,80);
  31. picture s=make_field(2,80);
  32. real margin=1cm;
  33. add(p.fit(),(0,0),margin*NW);
  34. add(q.fit(),(0,0),margin*NE);
  35. add(r.fit(),(0,0),margin*SW);
  36. add(s.fit(),(0,0),margin*SE);[/asy]`)
复制代码


  1. aops(`[asy]import graph;
  2. import palette;
  3. size(10cm,10cm,IgnoreAspect);
  4. real f(real x, real y) {
  5.   return 0.9*pow10(2*sin(x/5+2*y^0.25)) + 0.1*(1+cos(10*log(y)));
  6. }
  7. scale(Linear,Log,Log);
  8. pen[] Palette=BWRainbow();
  9. bounds range=image(f,Automatic,(0,1),(100,100),nx=200,Palette);
  10. xaxis("$x$",BottomTop,LeftTicks,above=true);
  11. yaxis("$y$",LeftRight,RightTicks,above=true);
  12. palette("$f(x,y)$",range,(0,200),(100,250),Top,Palette,
  13.         PaletteTicks(ptick=linewidth(0.5*linewidth())));
  14. [/asy]`)
复制代码


  1. aops(`[asy]import graph;
  2. size(9cm,8cm,IgnoreAspect);
  3. string data="westnile.csv";
  4. file in=input(data).line().csv();
  5. string[] columnlabel=in;
  6. real[][] A=in;
  7. A=transpose(A);
  8. real[] number=A[0], survival=A[1];
  9. path g=graph(number,survival);
  10. draw(g);
  11. scale(true);
  12. xaxis("Initial no.\\ of mosquitoes per bird ($S_{M_0}/N_{B_0}$)",
  13.       Bottom,LeftTicks);
  14. xaxis(Top);
  15. yaxis("Susceptible bird survival",Left,RightTicks(trailingzero));
  16. yaxis(Right);
  17. real a=number[0];
  18. real b=number[number.length-1];
  19. real S1=0.475;
  20. path h1=(a,S1)--(b,S1);
  21. real M1=interp(a,b,intersect(h1,g)[0]);
  22. real S2=0.9;
  23. path h2=(a,S2)--(b,S2);
  24. real M2=interp(a,b,intersect(h2,g)[0]);
  25. labelx("$M_1$",M1);
  26. labelx("$M_2$",M2);
  27. draw((a,S2)--(M2,S2)--(M2,0),Dotted);
  28. draw((a,S1)--(M1,S1)--(M1,0),dashed);
  29. pen p=fontsize(10pt);
  30. real y3=0.043;
  31. path reduction=(M1,y3)--(M2,y3);
  32. draw(reduction,Arrow,TrueMargin(0,0.5*(linewidth(Dotted)+linewidth())));
  33. arrow(shift(-20,5)*Label(minipage("\\flushleft{\\begin{itemize}\\item[1.]
  34. Estimate proportion of birds surviving at end of season\\end{itemize}}",100),
  35.                          align=NNE),
  36.       (M1,S1),NNE,1cm,p,Arrow(NoFill));
  37. arrow(shift(-24,5)*Label(minipage("\\flushleft{\\begin{itemize}\\item[2.]
  38. Read off initial mosquito abundance\\end{itemize}}",80),align=NNE),
  39.       (M1,0),NE,2cm,p,Arrow(NoFill));
  40. arrow(shift(20,0)*Label(minipage("\\flushleft{\\begin{itemize}\\item[3.]
  41. Determine desired bird survival for next season\\end{itemize}}",90),align=SW),
  42.       (M2,S2),SW,arrowlength,p,Arrow(NoFill));
  43. arrow(shift(8,-15)*Label(minipage("\\flushleft{\\begin{itemize}\\item[4.]
  44. Calculate required proportional reduction in mosquitoes\\end{itemize}}",90),
  45.                          align=NW),
  46.       point(reduction,0.5),NW,1.5cm,p,Arrow(NoFill));[/asy]`)
复制代码


  1. aops(`[asy]import graph;
  2. size(100);
  3. pair a=(0,0);
  4. pair b=(2pi,2pi);
  5. path vector(pair z) {return (0,0)--(sin(z.x),cos(z.y));}
  6. add(vectorfield(vector,a,b));[/asy]`)
复制代码

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2024-11-11 23:14
本帖最后由 hbghlyj 于 2024-11-12 08:06 编辑
kuing 发表于 2024-11-11 15:04
我困了,你研究下怎么改成 aops ,明天说吧



用于转发数据的php代码如下:
  1. <?php
  2. $data = array(
  3.         'action'=>'image',
  4.         'token'=>'igbhgvxm',
  5.         'tex'=>$_GET["tex"],
  6.         'rerender'=>false
  7. );
  8. $ch = curl_init();
  9. curl_setopt_array($ch, array(
  10.         CURLOPT_URL => "https://artofproblemsolving.com/m/texer/ajax.php",
  11.         CURLOPT_RETURNTRANSFER => true,
  12.         CURLOPT_POST => 1,
  13.         CURLOPT_SSL_VERIFYHOST => 0,
  14.         CURLOPT_SSL_VERIFYPEER => 0,
  15.         CURLOPT_HTTPHEADER => array('Content-Type: application/x-www-form-urlencoded'),
  16.         CURLOPT_POSTFIELDS => http_build_query($data)
  17. ));
  18. $result=curl_exec($ch);
  19. if(curl_errno($ch)){
  20.         die('Request Error:' . curl_error($ch));
  21. }
  22. $res=json_decode($result)->response->urls[0];
  23. header('Location: '.$res);
  24. ?>
复制代码

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

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

Powered by Discuz!

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