5907浏览
查看: 5907|回复: 2

[求助] makecode中三角函数的计算问题

[复制链接]
请教各位大神一个问题:makecode中如何计算三角函数?

東木青帝  见习技师

发表于 2018-4-18 09:08:33

这个需要你在程序中写入三条边的长度,a,b,c,然后利用余弦定理,可以计算出COSA、COSB、COSC 的数值。我写了一个,a=3,b=4,c=5的程序,部分截图,如下所示:
makecode中三角函数的计算问题图1
回复

使用道具 举报

東木青帝  见习技师

发表于 2018-4-18 09:09:55

[mw_shl_code=applescript,true]let item = 0
let c = 0
let y = 0
let b = 0
let x = 0
let a = 0
function doSomething() {
    x = b * b + c * c - a * a
    y = 2 * (b * c)
}
function doSomething2() {
    x = a * a + c * c - b * b
    y = 2 * (a * c)
}
function doSomething3() {
    x = a * a + b * b - c * c
    y = 2 * (a * b)
}
input.onButtonPressed(Button.A, () => {
    doSomething()
    basic.showString("COS" + "A" + "=" + item + "." + x * 100 / y)
})
input.onButtonPressed(Button.B, () => {
    doSomething2()
    basic.showString("COS" + "B" + "=" + item + "." + x * 100 / y)
})
input.onButtonPressed(Button.AB, () => {
    doSomething3()
    basic.showString("COS" + "C" + "=" + item + "." + x * 100 / y)
})
a = 3
b = 4
c = 5
item = x / y[/mw_shl_code]
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4

© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail