Jim Hurley <[EMAIL PROTECTED]>
 > Subject: Re: Button vs. Message box scripts

 Suppose I wanted to alter
 revRotatePoly  (or use it as a base for a new routine) so that the
 center of rotation was a point of my choosing rather then the
 graphic's loc.
----------
Well, I don't think that'd be a native thing, but here is a couple
alternatives I can think of:

1) Stretch the box that the graphic is in so that the image area is offset
from the actual loc by some dimension that will work for you.

2) Use the Animation Manager. Select it and open the Animation Manager,
click 'New', and set it to frame 1. Then rotate it manually (by message or
whatever), and move it over so that it appears to have moved around a
different axis, and apply that to whatever frame you like and test the
animation to see if it's the effect you want. Adjust it until it's right,
then put a [  revPlayAnimation "MyCrank" (or whatever)  ] handler in your
button.

HTH,
Ken N.



Ken,

Thanks for the suggestions. Actually it is possible, with minor variations to use a routine published in the digest a few issues ago to write a rotation routine that will rotate any polygon (or line) about any pivot point. This is a variation on a routine written by Derek Huby:

On mouseUP
  --Rotate a polygon "myPoly" about a button "Pivot" by 45 degrees
  rotatePoly "myPoly",the loc of button "Pivot", 45
end mouseUP

On rotatePoly theGraphic, thePivot, theAngle
  put the points of graphic theGraphic into tPoints

  put item 1 of thePivot into xPivot
  put item 2 of thePivot into yPivot

put empty into newPointList

repeat for each line tLine in tPoints --Set points relative to pivot
put (item 1 of tLine)- xPivot & "," & (item 2 of tLine)- yPivot & return after tRelPoints
end repeat


  put sin(theAngle* pi/180) into S
  put cos(theAngle * pi/180) into C

put empty into rotptlist

repeat for each line tLine in tRelPoints
put round(C*(item 1 of tLine)+ S*(item 2 of tLine) + xPivot) after rotPtlist
put "," after rotptlist
put round(-S*(item 1 of tLine) + C*(item 2 of tLine)+ yPivot)after rotPtlist
put return after rotPtList
end repeat


set the points of graphic theGraphic to rotPtlist

end rotatePoly

And a good tip from [EMAIL PROTECTED] To avoid distortions through repeated rotations one might store the original points set in a custom property of the graphic. You would also store the net angle of rotation as a property. So you start from scratch with each new rotation and avoid any accumulated distortion through round off errors.

Alejandro: I wasn't able to access the utilities you suggest form web site you mentioned. Problems with my version of Stuffit. I'll work on it. But thanks for the tip.

BTY I have found a matrix inversion routine in the archives. Works well and fast. 60 milliseconds to invert a 4x4. Of course the speed decreases rapidly with size.

Undocumented archania: Also, in examining the RR version of revRotatePoly I finally figured out what " get revPoints (graphic)" means. It takes a list of items and converts them to a single item, presumably for speed. That is a graphic pionts set obtained from "get the points of graphic...."

1,2
3,4
5,6

Looks like this when derived from "get revPoints(myGraphic)"

1,2,3,4,5,6

And the points are subsequently summed over k where k takes on the values 2*k-1 and 2*k, that is the odd and even entries in the item set. The odd number are item 1's and the even are item 2's. This would be valuable for all the speed demons out there.

Jim
_______________________________________________
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to