0) install gprolog under Linux
1) install clip
2) consult the following predicat
domino(A1,A2,Q) :-
{X1 = 20 * sin(A1), Y1 = 10 * cos(A1),
X2 = 20 * sin(A2), Y2 = 10 * cos(A2),
X3 = 0, Y3 = 0,
VX1 = X2 - X3, VY1 = Y2 - Y3,
VX2 = X1 - X2, VY2 = Y1 - Y2,
Q = VX1*VX2 + VY1*VY2
}.
by typing:
| ?- consult(domino).
and enter the following query
| ?-
reset_clip,
%reset the solver
{A1 >= 0,A1 =< (pi/2), A2 >= 0, A2 =< (pi/2),Q >= 0}, %add
constraint on A1,A2,Q
domino(A1,A2,Q),
%add the domino constraints
solve_clip([A1,A2,Q],0.01),
%solve the system with a precision of 0.01
print_clip([A1,A2,Q]).
%display the variables
for this query I have obtain the following result
[$INT(1),$INT(11),$INT(43)]
x(1)=
[1.57079632679489655799898173427,
1.5707963267948967800435866593]
x(11)=
[1.57079632679489655799898173427,
1.5707963267948967800435866593]
x(43)=
[0,
7.10542735760100185871124267578e-14]
it means that if there is solutions... there are in those intervals...
so certainly ther is no solution for those constraints.
Jul
PS: I have modified VY2 = Y2-Y3 to VY1 = Y2 - Y3.... because I think it
is a mistake...
address@hidden wrote:
I am new to GNU-Prolog and I have a problem that I wish to solve
(I am trying to write a domino game and am trying to figure out how to
lay
out the dominoes without them crossing). Below is an except from that
process.
Given two angles A1 and A2, X1 = 20*sin(A1), Y1 = 10*cos(A1), X2 =
20*sin(A2),
Y2 = 10*cos(A2). Also X3 = 0, Y3 = 0.
Let VX1 = X2-X3, VY2 = Y2-Y3, VX2 = X1-X2, VY2=Y1-Y2.
Compute a function Q = VX1*VX2+VY1*VY2.
Make the domain of A1 and A2 equal to 0 ... 90. Constrain the
expression Q > 0 to equal true. Minimize the sum of angles A1 and A2.
I have tried solving the problem myself, but I am getting errors. Can
anyone help me please :-)?
------------------------------------------------------------------------
_______________________________________________
Users-prolog mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/users-prolog
domino(A1,A2,Q) :-
{X1 = 20 * sin(A1), Y1 = 10 * cos(A1),
X2 = 20 * sin(A2), Y2 = 10 * cos(A2),
X3 = 0, Y3 = 0,
VX1 = X2 - X3, VY1 = Y2 - Y3,
VX2 = X1 - X2, VY2 = Y1 - Y2,
Q = VX1*VX2 + VY1*VY2
}.
_______________________________________________
Users-prolog mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/users-prolog