2

我是 Prolog 的新用户,我正在尝试缩放和变换地图中的坐标,但在缩放和变换 RULE上出现“未充分实例化”错误。这是我的规则,似乎参数没有充分实例化,请你给我解决方案如何解决这个问题。它接缝问题在于我使用“IS”运算符的比例和变换规则

transform_all :-
   forall(
      representation(Id, Geom),
      (  transform(Geom, TGeom),
         record_transformed_rep(Id, TGeom)
      )
   ).
transform_all :-
    forall(
       (  representation(Id, Geom),
          not(transformed_rep(Id))
       ),
       (  transform(Geom, TGeom),
          record_transformed_rep(Id, TGeom)
       )
    ).

%transformation
transform(Geom, TGeom) :-
   scale(Geom, value(10000), SGeom),
   translate(SGeom, value(-7.5, -51.9), TGeom).

%record_the_transformed_geometries
record_transformed_rep(Id, TGeom) :-
   retractall(representation(Id, _)),
   assert(representation(Id, TGeom)),
   assert(transformed_rep(Id)).  %% flag to avoid infinite loop

%scale_and_translate_metric_Map
scale(point(X,Y), value(V), point(Sx,Sy)) :-
   Sx is X * V,
   Sy is Y * V.

scale(polyline([]), value(_), polyline([])).
scale(polyline([P|R]), value(V), polyline([Sp|Sr])) :-
   scale(P,value(V),Sp),
   scale(polyline(R), value(V), polyline(Sr)).

%translate_coordinate_of_metric_map
translate(point(X,Y), value(Dx,Dy), point(Sx,Sy)) :-
   Sx is X + Dx,
   Sy is Y + Dy.

translate(polyline([]), value(_,_), polyline([])).
translate(polyline([P|R]), value(Dx,Dy), polyline([Sp|Sr])) :-
   translate(P,value(Dx,Dy),Sp),
   translate(polyline(R), value(Dx,Dy), polyline(Sr)). 
4

0 回答 0