Error in the documentation of rectInflate

Discussions related to Visual Prolog
User avatar
Ferenc Nagy
VIP Member
Posts: 343
Joined: 24 Apr 2007 12:26

Error in the documentation of rectInflate

Unread post by Ferenc Nagy » 29 Nov 2013 14:28

Hi,
vpi::rectInflate/3->
rectInflate : (
vpiDomains::rct Rectangle,
integer DHorizontal,
integer DVertical)
-> vpiDomains::rct ResizedRectangle
language c.

Changes the size of the specified Rectangle rectangle.


Description

Incorrect:

DHorizontal specifies the amount to increase or decrease the rectangle width. It must be negative to decrease the width.
DVertical specifies the amount to increase or decrease the rectangle height. It must be negative to decrease the height.
Returns the new rectangle ResizedRectangle calculated according to the following rule:


ResizedRectangle =
rct(Left - DHor, Top - DVert, Right + DHor, Bottom + DVert)

Correct:

DHorizontal specifies the half of the amount to increase or decrease the rectangle width. It must be negative to decrease the width.
DVertical specifies the half of the amount to increase or decrease the rectangle height. It must be negative to decrease the height.


I have tested it by adding some extra lines to the dev_boxer example program:

Code: Select all

try_start_stretch_boundary(Pnt)=Boundry:-         ZZ_BOX=zz_box,         RCT=vpi::rectInflate(zz_box, -30,-30),         stdio::write(ZZ_BOX),         stdio::nl,         stdio::write(RCT),         stdio::nl,

% 2013.11.29. NF added.
ZZ_BOX=vpiDomains::rct(ZZ_L,ZZ_T,ZZ_R,ZZ_B),
RCT=vpiDomains::rct(R_L,R_T,R_R,R_B),
stdio::writef("%5d %5d",ZZ_R-ZZ_L-(R_R-R_L),ZZ_B-ZZ_T-(R_B-R_T)),
stdio::nl,
% 2013.11.29. End of my additions.

Code: Select all

not(vpi::rectPntInside(RCT, Pnt)),         pnt_on_boundary(PNT,zz_box,Boundry),!,         retractall(db_stretch_boundary(_)),         assert(db_stretch_boundary(Boundry)).
Here I copy the result from the message window:
rct(83,141,261,253)
rct(113,171,231,223)
60 60
If the coordinates of the corners of the shrunk rectangle are
ResizedRectangle =
rct(Left - DHor, Top - DVert, Right + DHor, Bottom + DVert)
then its width and height has changed twofold, with 2*DHor and 2*DVert, respectively.

The error is the same as in the VIP 5 help file:
RCT /*ResizedRect =*/ rect_Inflate (RCT Rect, INTEGER DHor, INTEGER DVert)

Flow pattern (i, i, i)

Changes the size of the rectangle Rect.
Remarks

DHor specifies the amount to increase or decrease the rectangle width. It must be negative to decrease the width. DVert specifies the amount to increase or decrease the rectangle height. It must be negative to decrease the height.
Returns the new rectangle ResizedRect calculated according to the following rule:

ResizedRect = rct(Left - DHor, Top - DVert, Right + DHor, Bottom + DVert)
TIA, Regards,
Frank Nagy

Post Reply