我想绘制点 P 在相应坐标系 x'O'y'(蓝色)和 x''O''y''(绿色)上的投影。
我做了与 xOy 坐标系中相同的操作,但出现了如图所示的错误。
我的代码
size(8cm,0);
import geometry;
coordsys R=defaultcoordsys;
show("O",R);
coordsys Rp=cartesiansystem((0.5,0.5), i=(0.35,0.35), j=(-0.35,0.35));
show("O'", "$\vec{\imath'}$", "$\vec{\jmath'}$", Rp, ipen=blue);//, xpen=invisible);
coordsys Rpp=cartesiansystem((-1,-0.5),
i=rotate(-90)*(0.35,0.35),
j=rotate(-90)*(-0.35,0.35));
show("O''", "$\vec{\imath''}$", "$\vec{\jmath''}$", Rpp, ipen=green);//, xpen=invisible);
pair m=(1,1),
xm=(m.x,0),
ym=(0,m.y),
O=(0,0)
;
real r=5;
dot("",point(R,m),red);
markrightangle(size=r,point(R,xm),O,point(R,ym),red);
dot("",point(Rp,m),blue);
markrightangle(size=r,point(Rp,xm),point(Rp,O),point(Rp,ym),blue);
point M=m;
dot("",point(Rpp,M),green);
markrightangle(size=r,point(Rpp,xm),point(Rpp,O),point(Rpp,ym),green);
pair p=(0.75,-0.75);
point P=point(R,p),
PR=P,
xPR=(point(R,p).x,0),
yPR=(0,point(R,p).y),
PRp=point(Rp,p),
xPRp=(point(Rp,p).x,0),
yPRp=(0,point(Rp,p).y),
PRpp=point(Rpp,p),
xPRpp=(point(Rpp,p).x,0),
yPRpp=(0,point(Rpp,p).y)
;
dot("$P$",P,2E,4mm+red);
dot("$P'$",point(Rp,p/Rp),2S,3mm+blue);
dot("$P''$",changecoordsys(Rpp,P),2W,1.5mm+green);
draw(xPR--PR--yPR,dashed+red);
//draw(xPRp--PRp--yPRp,dashed+blue);
//draw(xPRpp--PRpp--yPRpp,dashed+green);
pair px[]={xPR,yPR};
string sx[]={"$x_\mathrm{PO}$","$y_\mathrm{PO}$"};
int gx[]={90,180};
for(int ii=0; ii<px.length;++ii )dot(sx[ii],px[ii],dir(gx[ii]),Fill(white));
addMargins(1cm,1cm);
答案1
请找出两种解决方案。第一种解决方案用于changecoordsys
恢复系统坐标中点的x
和y
坐标。第二种解决方案使用正交投影。P
Rp
size(8cm,0);
import geometry;
coordsys R=defaultcoordsys;
show("O",R);
coordsys Rp=cartesiansystem((0.5,0.5), i=(0.35,0.35), j=(-0.35,0.35));
show("O'", "$\vec{\imath'}$", "$\vec{\jmath'}$", Rp, ipen=blue);//, xpen=invisible);
coordsys Rpp=cartesiansystem((-1,-0.5),
i=rotate(-90)*(0.35,0.35),
j=rotate(-90)*(-0.35,0.35));
show("O''", "$\vec{\imath''}$", "$\vec{\jmath''}$", Rpp, ipen=green);//, xpen=invisible);
pair m=(1,1),
xm=(m.x,0),
ym=(0,m.y),
O=(0,0)
;
real r=5;
dot("",point(R,m),red);
markrightangle(size=r,point(R,xm),O,point(R,ym),red);
dot("",point(Rp,m),blue);
markrightangle(size=r,point(Rp,xm),point(Rp,O),point(Rp,ym),blue);
point M=m;
dot("",point(Rpp,M),green);
markrightangle(size=r,point(Rpp,xm),point(Rpp,O),point(Rpp,ym),green);
pair p=(0.75,-0.75);
point P=point(R,p);
point xPR=(point(R,p).x,0);
point yPR=(0,point(R,p).y);
// 1st solution
point zPRp=changecoordsys(Rp,P);
point xPRp=point(Rp,(zPRp.x,0));
point yPRp=point(Rp,(0,zPRp.y));
// 2nd solution
point xPRpp=projection(Rpp.O,Rpp.O+Rpp.i)*P;
point yPRpp=projection(Rpp.O,Rpp.O+Rpp.j)*P;
dot("$P$",P,2E,4mm+red);
dot("$P'$",point(Rp,p/Rp),2S,3mm+blue);
dot("$P''$",changecoordsys(Rpp,P),2W,1.5mm+green);
draw(xPR--P--yPR,dashed+red);
draw(xPRp--P--yPRp,dashed+blue);
draw(xPRpp--P--yPRpp,dashed+green);
pair px[]={xPR,yPR};
string sx[]={"$x_\mathrm{PO}$","$y_\mathrm{PO}$"};
int gx[]={90,180};
for(int ii=0; ii<px.length;++ii )dot(sx[ii],px[ii],dir(gx[ii]),Fill(white));
addMargins(1cm,1cm);
结果