gpt4 book ai didi

javascript - 是什么导致未捕获的类型错误 : number is not a function?

转载 作者:行者123 更新时间:2023-12-04 02:31:29 25 4
gpt4 key购买 nike

如您所知,我正在尝试组装一个非常简单的 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);

最佳答案

你需要使用*来相乘:

dx = Math.cos(a[1])*(Math.sin(a[2])*(point[1] - c[1]) ... etc

关于javascript - 是什么导致未捕获的类型错误 : number is not a function?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5467505/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com