在eclipse clp中使用三角函数

时间:2013-06-30 10:38:40

标签: math prolog logic constraint-programming eclipse-clp

我是新手来蚀掉CLP,我想实现一个谓词,它可以获得与特定正弦函数相当的所有角度,例如

:- lib(ic).
solve(L) :-
L = [X,Y,Z],
L::[-180..180],
cos(X) #= sin(Y) + sin(Z),
labeling(L).

我知道这个方案可能适用于变量的整数值;所以我需要一个也使用CLP的替代解决方案。

2 个答案:

答案 0 :(得分:1)

好的我明白了,

:-lib(ic).
solve(V):-
V = [X,Y,Z],
V::[0 .. 180],
cos(X*pi/180) $= sin(Y*pi/180) + sin(Z*pi/180),
labeling(V).

N.B:cos和sin谓词用弧度

答案 1 :(得分:0)

三角函数参数以弧度为单位。

使用公式Rad = Degree * pi / 180进行转换。