Vispatch Tutorial (using Java 1.02) > TOC > The Vispatch Visual Language > Bodies of Rules > GenXY

GenXY

Intuitively, GenXY points are generated relative to the mouse drag event such that X and Y distances are scaled independently in relation to the X and Y distance covered by the mouse drag. More precisely, it generates a new point based on the the same five points as used by GenRotate, except that GenXY point is used instead of the GenRotate point. These points are described on the previous page. Call the X coordinate of these five points mouseDragBegin.X, mouseDragEnd.X, dragInBodyBegin.X, dragInBodyEnd.X, and GenRotate.X.

The X coordinate, newPoint.X, is generated such that the ratio
(newPoint.X - mouseDragBegin.X) / (mouseDragEnd.X - mouseDragBegin.X)
is equal to the ratio
(GenRotate.X - dragInBodyBegin.X) / (dragInBodyEnd.X - dragInBodyBegin.X).

The Y coordinate is generated similarly.

 
Notice that to compute the new point, GenXY must perform division by the X and Y distance between dragInBodyBegin and dragInBodyEnd. Therefore, these must not be placed horizontally or vertically, which would result in division by zero.