Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Lua 偏航、俯仰和滚转旋转到六个浮动变量_Lua_Calculus_Angle - Fatal编程技术网

Lua 偏航、俯仰和滚转旋转到六个浮动变量

Lua 偏航、俯仰和滚转旋转到六个浮动变量,lua,calculus,angle,Lua,Calculus,Angle,我需要帮助创建一个函数,将三个角度(以度为单位,偏航、俯仰和横摇)转换为六个浮动变量 我如何让函数输出这些浮点值 {0,0,0}={1,0,0,-0,-0,1} {45,0,0}={0.70710676908493,0.70710676908493,0,-0,-0,1} {0,90,0}={-4.3711388286738e-08,0,1,-1,0,-4.3711388286738e-08} {0,0,135}={1,-0,0,-0,-0.70710676908493,-0.707106769

我需要帮助创建一个函数,将三个角度(以度为单位,偏航、俯仰和横摇)转换为六个浮动变量


我如何让函数输出这些浮点值

  • {0,0,0}={1,0,0,-0,-0,1}
  • {45,0,0}={0.70710676908493,0.70710676908493,0,-0,-0,1}
  • {0,90,0}={-4.3711388286738e-08,0,1,-1,0,-4.3711388286738e-08}
  • {0,0,135}={1,-0,0,-0,-0.70710676908493,-0.70710676908493}
  • {180,180,0}={1,-8.7422776573476e-08,8.7422776573476e-08,8.7422776573476e-08,0,-1}
  • {225,0225}={-0.70710682868958,0.5,0.5,-0,0.70710670948029,-0.70710682868958}
  • {270270270}={1.4220277639103e-16,-2.3849761277006e-08,1,1,1.1924880638503e-08,1.42202776319103e-16}
  • {315315315}={0.5,-0.85355341434479,0.1464468917263,0.70710688829422,0.5,0.5}
更多示例由:Egor Skriptunoff请求

  • {10,20,30}={0.92541658878326,-0.018028322607279,0.37852230668068,-0.34202012419701,-0.46984630823135,0.8137976527241}
  • {10,30,20}={0.85286849737167,-0.0052361427806318,0.52209949493408,-0.5,-0.29619812965393,0.81379765272141}
  • {20,10,30}={0.92541658878326,0.21461015939713,0.312345537281,-0.17364817857742,-0.49240386486053,0.85286849737167}
  • {20,30,10}={0.81379765272141,0.25523611903191,0.52209949493408,-0.5,-0.15038372576237,0.85286849737167}
  • {30,10,20}={0.85286849737167,0.41841205954552,0.312325537281,-0.17364817857742,-0.33682405948639,0.92541658878326}
  • {30,20,10}={0.81379765272141,0.4409696161747,0.37852230668068,-0.34202012419701,-0.16317591071129,0.92541658878326}
我目前拥有的代码可以计算除第二个和第三个之外的所有浮动

function convert_rotations(Yaw, Pitch, Roll)
    return {
        math.cos(math.rad(Yaw))*math.cos(math.rad(Pitch)),
        0,
        0,
        math.sin(math.rad(Pitch))*-1,
        math.sin(math.rad(Roll))*math.cos(math.rad(Pitch))*-1,
        math.cos(math.rad(Roll))*math.cos(math.rad(Pitch))
    }
end
对于第二个和第三个浮点数,当所有角度均为非零时,我似乎无法找到正确的数学公式,但我确实得出了以下结论:

-- The second float when the Yaw is 0 degrees
math.sin(math.rad(Pitch))*math.sin(math.rad(Roll))*-1

-- The second float when the Pitch is 0 degrees
math.sin(math.rad(Yaw))*math.cos(math.rad(Roll))

-- The second float when the Roll is 0 degrees
math.sin(math.rad(Yaw))*math.sin(math.rad(Pitch))
-- The third float when Yaw is 0 degrees
math.sin(math.rad(Pitch))*math.cos(math.rad(Roll))

-- The third float when Pitch is 0 degrees
math.sin(math.rad(Yaw))*math.sin(math.rad(Roll))

-- The third float when Roll is 0 degrees
math.cos(math.rad(Yaw))*math.sin(math.rad(Pitch))
在第三次花车上,我想到了这个:

-- The second float when the Yaw is 0 degrees
math.sin(math.rad(Pitch))*math.sin(math.rad(Roll))*-1

-- The second float when the Pitch is 0 degrees
math.sin(math.rad(Yaw))*math.cos(math.rad(Roll))

-- The second float when the Roll is 0 degrees
math.sin(math.rad(Yaw))*math.sin(math.rad(Pitch))
-- The third float when Yaw is 0 degrees
math.sin(math.rad(Pitch))*math.cos(math.rad(Roll))

-- The third float when Pitch is 0 degrees
math.sin(math.rad(Yaw))*math.sin(math.rad(Roll))

-- The third float when Roll is 0 degrees
math.cos(math.rad(Yaw))*math.sin(math.rad(Pitch))

这里的问题到底是什么?数学?密码?还有别的吗?你已经尝试过了吗?我该如何让函数输出这些浮点数呢?我假设的数学包括math.rad、math.cos、math.sin和math.tan,但我不确定所有这些内容通常是如何组合在一起的。你有一些格式的输入吗?那些是桌子吗?你知道其中涉及的数学是什么吗?你能写/你写了/你有数学库吗?输入的是偏航、俯仰和滚转的度数。我相信输出是矩阵。我有可以计算前两个浮动的代码,但只有当俯仰和滚动旋转设置为0时。数学是{math.cos(math.rad(yaw)),math.sin(math.rad(yaw))}。输出与矩阵不完全一样。如果是矩阵,它们需要是4x4(因此,即使我们假设没有转换,我们仍然会得到九个值)。六个值可以在2D中工作,但我们不需要三个角度。你能告诉我们你从哪里得到这些例子吗?这是大学的工作吗?