是什么导致Uncaught TypeError:number不是函数?

Tyl*_*coe 2 javascript 3d

你可以告诉我,我正在尝试组建一个非常简单的3D引擎.我是用javascript写的.我认为公式中可能存在错误,但对于我的生活,我找不到它.所以现在我想可能还有其他我尚未考虑的事情.错误发生在第21行(dx = Math.cos .....)

这是我的代码的相关部分:

// Camera Position in x,y,z
var c = [ 0,0,0 ];

// Viewer position [x,y,z]
var v = [ 0,0,0 ];

// Angle of view [x, y, z]
var a = [ 0.01, 0.01, 0.01 ];

var point =  [ 0,0, 50 ];

dx = Math.cos(a[1])(Math.sin(a[2])(point[1] - c[1]) + Math.cos(a[2])(point[0] - c[0])) - Math.sin(a[1])(point[2] - c[2]);
dy = Math.sin(a[0])(Math.cos(a[1])(point[2] - c[2]) + Math.sin(a[1])(Math.sin(a[2])(point[1] - c[1]) + Math.cos(a[2])(point[0] - c[0]))) + Math.cos(a[0])(Math.cos(a[2])(point[1] - c[1]) - Math.sin(a[2])(point[0] - c[0]));
dz = Math.cos(a[0])(Math.cos(a[1])(point[2] - c[2]) + Math.sin(a[1])(Math.sin(a[2])(point[1] - c[1]) + Math.cos(a[2])(point[0] - c[0]))) - Math.sin(a[0])(Math.cos(a[2])(point[1] - c[1]) - Math.sin(a[2])(point[0] - c[0]));

bx = (dx - v[0])(v[2]/dz);
by = (dy - v[1])(v[2]/dz);
Run Code Online (Sandbox Code Playgroud)

mVC*_*Chr 5

您需要使用*乘法:

dx = Math.cos(a[1])*(Math.sin(a[2])*(point[1] - c[1]) ... etc
Run Code Online (Sandbox Code Playgroud)