Message: 3 Date: Fri, 5 Mar 2004 11:28:48 -0500 From: "Springer, Paul" <[EMAIL PROTECTED]> Subject: RE: Rotating Graphics To: 'How to use Revolution' <[EMAIL PROTECTED]> Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain

Dar,

Thanks for the help. As a beginner with RR, I need a little clarification.

1. When you say "Rotate that." Do you mean with a built in command or with a
custom command that is re-calculating where the points should be?

2. Aren't there points already defined for the polygons vertices? Do I need
to somehow use my custom properties instead of those?

-Paul


Hi Paul,


This is tricky stuff in the beginning.

What follows is a variation on something developed by the list. It avoids the rounding errors you have encountered, following Dar Scott's suggestion, by using a set of custom properties.

There are two components, setAngle and rotatePoly. The latter just sets the angle to the existing angle plus the degree of rotation.

You can script the construction of the custom properties, for example

set the defaultPoints of grc "myPoly" to the points of grc "myPoly"
set the pivotPoint of grc "myPoly" to line 1 of the points of graphic "myPoly"
set the theAngle of grc "myPoly" to 0



On mouseUP --Rotate a polygon 8 times by an angle of 45 about a pivot point repeat 8 rotatePoly "myPoly", 45 wait 20 ticks --Slow it down so you can see it. end repeat end mouseUP

On setAngle tGraphic, tAngle
--Uses three custom properties of the polygon
--1) A default angle called "theAngle" used to define the initial orientation
--2) A set of default points used to define the initial shape: "defaultPoints"
--3) A pivot point "pivotPoint"


  set the theAngle of grc tGraphic to tAngle
  put the defaultPoints of graphic tGraphic into tPoints
  put the pivotPoint of grc tGraphic into tPivot
  put item 1 of tPivot into xPivot
  put item 2 of tPivot into yPivot

put empty into newPointList

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

--Set points relative to pivot
repeat for each line tLine in tPoints
put (item 1 of tLine)- xPivot into theX
put (item 2 of tLine)- yPivot into theY
put round(C*theX+ S*theY + xPivot)& comma after rotPtlist
put round(-S*theX + C*theY+ yPivot)after rotPtlist
put return after rotPtList
end repeat
set the points of graphic tGraphic to rotPtlist
end setAngle


on rotatePoly tGraphic, tChange
  put the theAngle of grc tGraphic into tAngle
  setAngle tGraphic, tAngle+tChange
end rotatePoly
_______________________________________________
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to