Button vs. Message box scripts AND things rotational
jhurley at infostations.com
Wed Apr 2 12:53:00 EST 2003
> Jim Hurley <jhurley at infostations.com>
> > 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
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
--Rotate a polygon "myPoly" about a button "Pivot" by 45 degrees
rotatePoly "myPoly",the loc of button "Pivot", 45
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
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)
put "," after rotptlist
put round(-S*(item 1 of tLine) + C*(item 2 of tLine)+
put return after rotPtList
set the points of graphic theGraphic to rotPtlist
And a good tip from Cubist at aol.com. 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
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...."
Looks like this when derived from "get revPoints(myGraphic)"
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.
More information about the Use-livecode