📄 3dmaths.inc
字号:
{* ______ ___ ___
* /\ _ \ /\_ \ /\_ \
* \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
* \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
* \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
* \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
* \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
* /\____/
* \_/__/
*
* 3D maths inline functions (generic C).
*
* By Shawn Hargreaves.
*
* See readme.txt for copyright information.
*}
{$IFDEF ALLEGRO_INTERFACE}
function dot_product(x1, y1, z1, x2, y2, z2: fixed): fixed;
function dot_product_f(x1, y1, z1, x2, y2, z2: single): single;
procedure persp_project(x, y, z: fixed; var xout, yout: fixed);
procedure persp_project_f(x, y, z: single; var xout, yout: single);
{$ENDIF ALLEGRO_INTERFACE}
{$IFDEF ALLEGRO_IMPLEMENTATION}
function dot_product(x1, y1, z1, x2, y2, z2: fixed): fixed;
begin
Result := fixmul(x1, x2) + fixmul(y1, y2) + fixmul(z1, z2);
end;
function dot_product_f(x1, y1, z1, x2, y2, z2: single): single;
begin
Result := (x1 * x2) + (y1 * y2) + (z1 * z2);
end;
procedure persp_project(x, y, z: fixed; var xout, yout: fixed);
begin
xout := fixmul(fixdiv(x, z), _persp_xscale^) + _persp_xoffset^;
yout := fixmul(fixdiv(y, z), _persp_yscale^) + _persp_yoffset^;
end;
procedure persp_project_f(x, y, z: single; var xout, yout: single);
var
z1: single;
begin
z1 := 1.0 / z;
xout := ((x * z1) * _persp_xscale_f^) + _persp_xoffset_f^;
yout := ((y * z1) * _persp_yscale_f^) + _persp_yoffset_f^;
end;
{$ENDIF ALLEGRO_IMPLEMENTATION}
{$IFDEF ALLEGRO_LOADVARIABLE}
{$ENDIF ALLEGRO_LOADVARIABLE}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -