Domanda

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.

È stato utile?

Soluzione

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

N.B: the cos and sin predicates work with radians

Altri suggerimenti

Trigonometric function arguments are in radians.

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top