所以我正在开发一个允许我计算我投入游戏的模型的子对象法线的过程。基本上,我知道如何计算它们,但我需要创建一个可以使用这段代码的函数。
local sin, asin = math.sin, math.asin
local deg, rad = math.deg, math.rad
math.sin = function (x) return sin(rad(x)) end
math.asin = function (x) return asin(deg(x)) end --Makes math.sin read in degrees instead of radians
x = function (sin (a))
z = function (sin (b))
y = function (sin (c))
d = {a, b, c}
end
e = {x, z, y}
end
repeat
print("Enter a value for x:")
a = io.read("*number") -- read a number
print(math.sin(a))
print("Do you want to repeat? Type 1 to repeat")
a = io.read("*number")
until a ~= 1
它的工作方式是子对象旋转的角度的正弦值成为该轴上的正常值。 (z = b因为Blender以X-Y水平运行,游戏处于X-Z水平位置)
基本上,我正在寻找一个允许我输入“数组d”的函数,并将输出显示为“数组e”而不是单个输出函数。 a,b和c是变量,而不是常量。
答案 0 :(得分:0)
python中的函数可以定义为 -
def myfunc(a,b,c):
x = sin (a)
z = sin (b)
y = sin (c)
return x,y,z
或者您可以输入数组 -
def myfunc(arr):
x = sin (arr[0])
z = sin (arr[1])
y = sin (arr[2])
return {x,y,z}
请注意,您可以根据需要返回以不同方式存储的多个号码。