简体   繁体   中英

Using trigonometric functions in eclipse clp

I'm new to eclipse CLP and I want to implement a predicate that gets all the angles equivalent to a specific sinusoidal function, something like

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

I know that this scheme probably works for integral values of the variables; so I need an alternative solution that also uses CLP.

Ok I figured it out,

:-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).

NB: the cos and sin predicates work with radians

Trigonometric function arguments are in radians.

Use the formula Rad = Degree * pi / 180 to convert.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM