return [((fol/v[2])*v[0]+x),((fol/v[2])*v[1]+y)];
点[0,0,1]将是x=0和y=0,除非您添加中心屏幕xy-它不是相机xy。fol是焦距,由fov角度和屏幕宽度推导出来的-三角形有多高(正切)。这种方法将无法匹配three.js透视矩阵,这就是为什么我在寻找它的原因。
我不应该寻找它。我在openGL上完美地匹配了xy,就像超级胶水一样!但是我无法使其在java中正常工作。那个完美的匹配如下。
var pmat = [0,0,0,0,0,0,0,0,0,0,
(farclip + nearclip) / (nearclip - farclip),-1,0,0,
2*farclip*nearclip / (nearclip - farclip),0 ];
void setpmat() {
double fl;
fl = 1/tan(dtor(fov/Aspect/2));
pmat[0] = fl/Aspect;
pmat[5] = fl;
}
void fovmat(double v[],double p[]) {
int cx = (int)(_Width/2),cy = (int)(_Height/2);
double pnt2[4], pnt[4] = { 0,0,0,1 } ;
COPYVECTOR(pnt,p);NORMALIZE(pnt);
popmatrix4(pnt2,pmat,pnt);
COPYVECTOR(v,pnt2);
v[0] *= -cx; v[1] *= -cy;
v[0] += cx; v[1] += cy;
}
void w2sm(int xy[],double p[]) {
double v[3]; fovmat(v,p);
xy[0] = (int)v[0];
xy[1] = (int)v[1];
}
我有另一种匹配three.js xy的方法,直到我让矩阵工作,只有一个条件。必须以2的宽高比运行。
function w2s(fol,v,x,y) {
var a = width / height;
var b = height/width ;
var f = 1/Math.tan(dtor(_fov/a)) * x * b;
return [intr((f/v[2])*v[0]+x),intr((f/v[2])*v[1]+y)];
}
使用反转的相机矩阵,需要使用invert_matrix()函数。
v = orbital(i);
v = subv(v,campos);
v3 = popmatrix(wmatrix,v);
if (v3[2] > 0) {
xy = w2s(flen,v3,cx,cy);
终于来了,(现在每个人都应该知道),无矩阵匹配,任何方面。
function angle2fol(deg,centerx) {
var b = width / height;
var a = dtor(90 - (clamp(deg,0.0001,174.0) / 2));
return asa_sin(PI_5,centerx,a) / b;
}
function asa_sin(a,s,b) {
return Math.sin(b) * (s / Math.sin(PI-(a+b)));
}
function w2s(fol,v,x,y) {
return [intr((fol/v[2])*v[0]+x),intr((fol/v[2])*v[1]+y)];
}
更新了证明的图像。输入_fov会得到1.5倍,"大约"。为了正确查看FOV读数,请使用新的焦距重新绘制三角形。
function afov(deg,centerx) {
var f = angle2fol(deg,centerx);
return rtod(2 * sss_cos(f,centerx,sas_cos(f,PI_5,centerx)));
}
function sas_cos(s,a,ss) {
return Math.sqrt((Math.pow(s,2)+Math.pow(ss,2))-(2*s*ss*Math.cos(a)));
}
function sss_cos(a,b,c) {
with (Math) {
return acos((pow(a,2)+pow(c,2)-pow(b,2))/(2*a*c));
}
}
Star library确认了视角,那么可以测量VIEW!http://innerbeing.epizy.com/cwebgl/perspective.jpg
我可以用一个词“岁差”来解释对月球北极进行90度校正。那么当前的上向量是什么?pnt?radec?
function ininorths() {
if (0) {
var c = ctime;
var v = LunarPos(jdm(c));
c += secday();
var vv = LunarPos(jdm(c));
vv = crossprod(v,vv);
v = eyeradec(vv);
echo(v,vv);
v = [266.86-90,65.64];
}
var v = [282.6425,65.8873];
}
我还没有解释两组向量:Three.milkyway.matrix 和 3D 到 2D 绘图。它们是:
function drawmilkyway() {
var v2 = radec2pos(dtor(192.8595), dtor(27.1283),75000000);
var v3 = radec2pos(dtor(266.4168), dtor(-29.0078),75000000);
}
function initmwmat() {
var r,u,e;
e = radec2pos(dtor(156.35), dtor(12.7),1);
u = radec2pos(dtor(60.1533), dtor(25.5935),1);
r = normaliz(crossprod(u,e));
u = normaliz(crossprod(e,r));
e = normaliz(crossprod(r,u));
var m = MilkyWayMatrix;
m[0]=r[0];m[1]=r[1];m[2]=r[2];m[3]=0.0;
m[4]=u[0];m[5]=u[1];m[6]=u[2];m[7]=0.0;
m[8]=e[0];m[9]=e[1];m[10]=e[2];m[11]=0.0;
m[12]=0.0;m[13]=0.0;m[14]=0.0;m[15]=1.0;
}
void initmwmat(double m[16]) {
double r[3], u[3], e[3];
radec2pos(e,dtor(192.8595), dtor(27.1283),1);
radec2pos(u,dtor(266.4051), dtor(-28.9362),-1);
}